next.js
7147642e - [devtools]: instrument client navigation hooks for suspense devtools (#85007)

Commit
111 days ago
[devtools]: instrument client navigation hooks for suspense devtools (#85007) Various navigation hooks (eg `usePathname`, `useParams`) could suspend during SSR/prerendering even though they don't necessarily suspend during client side navigation (because it was likely part of a prefetch response). React's Suspense DevTools show all the possible things that could have suspended on the page, but without us calling `use` in these hooks, there'd be no way for React to track them as IO in the same way that we do during prerendering. In development, this instruments all of the client navigation hooks to call `use` on a fulfilled promise set to the same value that we would have returned previously. For hooks like `useSelectedLayoutSegment`, I'm storing a map of promises at each level of layout (because these hooks take a parallel route key argument and values are relative to the calling layout's position in the tree). These are eagerly pre-computed during dev.
Author
Parents
Loading