({currentPage, pages, children})
| 114 | const RouterContext = createContext<RouterContextValue | null>(null); |
| 115 | |
| 116 | export function Router({currentPage, pages, children}) { |
| 117 | let snapshot = useDelayedSnapshot(); |
| 118 | let displayPage = snapshot.promise ? getPageFromPathname(pages, snapshot.pathname) : currentPage; |
| 119 | |
| 120 | return ( |
| 121 | <RouterContext value={{currentPage: displayPage, pages, isLoading: !!snapshot.promise}}> |
| 122 | {children} |
| 123 | </RouterContext> |
| 124 | ); |
| 125 | } |
| 126 | |
| 127 | export function useRouter(): RouterContextValue { |
| 128 | return useContext(RouterContext)!; |
nothing calls this directly
no test coverage detected