MCPcopy Create free account
hub / github.com/adobe/react-spectrum / MemoryRouter

Function MemoryRouter

packages/dev/s2-docs/pages/s2/router.tsx:23–29  ·  view source on GitHub ↗
(props: {initialEntries?: string[]; children: ReactNode})

Source from the content-addressed store, hash-verified

21});
22
23export function MemoryRouter(props: {initialEntries?: string[]; children: ReactNode}) {
24 let {initialEntries = ['/'], children} = props;
25 let [location, setLocation] = useState<Location>({pathname: initialEntries[0]});
26 let navigate = (pathname: string) => setLocation({pathname});
27
28 return <RouterContext.Provider value={{location, navigate}}>{children}</RouterContext.Provider>;
29}
30
31export function useLocation(): Location {
32 return useContext(RouterContext).location;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected