rsnext/packages
Zack Tanner f93ae7c89e
fix TypeError edge-case for parallel slots rendered multiple times (#64271)
### What
When rendering a parallel slot multiple times in a single layout, in
conjunction with using an error boundary, the following TypeError is
thrown:

> Cannot destructure property 'parallelRouterKey' of 'param' as it is
null

### Why
I'm not 100% sure of the reason, but I believe this is because of how
React attempts to dededupe (more specifically, "detriplficate") objects
that it sees getting passed across the RSC -> client component boundary
(and an error boundary is necessarily a client component). When React
sees the same object twice, it'll create a reference to that object and
then use that reference in future places where it sees the object. My
assumption is that there's a bug somewhere here, as the `LayoutRouter`
component for the subsequent duplicated parallel slots (after the first
one) have no props, hence the TypeError.

### How
Rather than passing the error component as a prop to `LayoutRouter`,
this puts it as part of the `CacheNodeSeedData` data structure. This is
more aligned with other properties anyway (such as `loading` and `rsc`
for each segment), and seems to work around this bug as the
`initialSeedData` prop is only passed from RSC->client once.

EDIT: Confirmed this is also fixed after syncing the latest React, due
to https://github.com/facebook/react/pull/28669

Fixes #58485
Closes NEXT-2095
2024-04-17 01:18:06 +00:00
..
create-next-app v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
eslint-config-next v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
eslint-plugin-next v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
font v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next fix TypeError edge-case for parallel slots rendered multiple times (#64271) 2024-04-17 01:18:06 +00:00
next-bundle-analyzer v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-codemod v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-env v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-mdx v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-plugin-storybook v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-polyfill-module v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-polyfill-nomodule v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
next-swc v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
react-refresh-utils v14.3.0-canary.6 2024-04-16 23:22:28 +00:00
third-parties v14.3.0-canary.6 2024-04-16 23:22:28 +00:00