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

Function Router

packages/dev/s2-docs/src/Router.tsx:116–125  ·  view source on GitHub ↗
({currentPage, pages, children})

Source from the content-addressed store, hash-verified

114const RouterContext = createContext<RouterContextValue | null>(null);
115
116export 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
127export function useRouter(): RouterContextValue {
128 return useContext(RouterContext)!;

Callers

nothing calls this directly

Calls 2

useDelayedSnapshotFunction · 0.85
getPageFromPathnameFunction · 0.85

Tested by

no test coverage detected