Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use prefetched segment data on initial render
When PPR is enabled, there are two different versions of a segment's data we can render: a static version (that may contain holes for the dynamic parts) and a full version that contains everything. The static version is prefetched before navigation, and the full version is only loaded once the navigation occurs. Both versions are stored on the Cache Node object. Inside LayoutRouter, we must choose which version to render. We'll use an experimental feature of React's `useDeferredValue` hook: facebook/react#27500 ```js const dataToRender = useDeferredValue(fullData, prefetchedData) ``` React will coordinate when to switch from the prefetch data to the full data. For example, if the prefetch data is unable to finish rendering (this would happen if the segment contained dynamic data that was not wrapped in a Suspense boundary), it knows to switch to the full data even though the first render did not commit.
- Loading branch information