Skip to content

Commit

Permalink
feat(prxojects): change useRouter declaration type
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohh-889 committed Aug 31, 2024
1 parent a75c25e commit f27d4c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/simple-router/src/hooks/useRouter/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { createContext, useContext } from 'react';
import type { Router } from '../../types';

import Router from '../../router'

export const RouterContext = createContext<Router>({} as Router);
export function useRouter() {
const router = useContext(RouterContext);
if (!router) {
throw new Error('useRouter must be used within a Provider');
}

return router;
}

0 comments on commit f27d4c3

Please # to comment.