import React , { createContext , useContext , useMemo } from 'react' ; const BasePathContext = createContext ( '' ) ; const PathContext = createContext < string | null > ( null ) ; export { BasePathContext } ; export { PathContext } ; export function useRouter ( ) { const [ basePath , path ] = [ useContext ( BasePathContext ) , useContext ( PathContext ) ] ; return useMemo ( ( ) => ( { basePath , path } ) , [ basePath , path ] ) ; } export function RouterProvider ( { basePath = '' , path , children , } ) { return ( < BasePathContext . Provider value = { basePath } > < PathContext . Provider value = { path ?? null } > { children } < /PathContext.Provider> < /BasePathContext.Provider>); }