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

Function usePendingPage

packages/dev/s2-docs/src/Router.tsx:131–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129}
130
131export function usePendingPage(): Page {
132 let {pages, currentPage} = useRouter();
133 let [snapshot, setSnapshot] = useState(getSnapshot());
134 let pendingPage = snapshot.pathname ? getPageFromPathname(pages, snapshot.pathname) : null;
135
136 useEffect(() => {
137 return subscribe(() => {
138 setSnapshot(getSnapshot());
139 });
140 }, []);
141
142 return pendingPage ?? currentPage;
143}
144
145export function Main(props) {
146 // Reset key when page changes. This causes the content to scroll to the top.

Callers 1

NavFunction · 0.90

Calls 4

getPageFromPathnameFunction · 0.85
useRouterFunction · 0.70
getSnapshotFunction · 0.70
subscribeFunction · 0.70

Tested by

no test coverage detected