import React , { useContext } from 'react' ; import { RouterStore } from '../stores' ; export const RouterContext = React . createContext < RouterStore | undefined > ( undefined ) ; export function useRouterStore ( ) { const routerStore = useContext ( RouterContext ) ; if ( routerStore === undefined ) { throw new Error ( 'useRouterStore must be used within a RouterStoreProvider' ) ; } return routerStore ; }