-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot destructure property 'parallelRouterKey' of 'param' as it is null. #58485
Comments
I discovered that this also happens when rendering a parallel route twice: function Layout({ route }) {
return <>
{route}
{route}
</>
} removing one of the instances makes the error go away but as soon as two or more are rendered it throws "TypeError: Cannot destructure property 'parallelRouterKey' of 'param' as it is null." tested on Next.js 14.0.3 |
Issue is still happing with:
|
Facing same issue with Update: @sebpalluel I was able to solve the issue by wrapping the |
…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 facebook/react#28669 Fixes #58485 Closes NEXT-2095
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/sebpalluel/parallel-router-key-destructure-property-error
To Reproduce
pnpm i
pnpm run dev
http://localhost:3000/
is working, displaying a layout with parallel routes displayed conditionally in desktop or mobile view size.http://localhost:3000/dummy
. It will display an error message coming fromnext/dist/client/components/layout-router.js
"TypeError: Cannot destructure property 'parallelRouterKey' of 'param' as it is null."Current vs. Expected behavior
It should display the placeholder
not-found.txs
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 Binaries: Node: 20.1.0 npm: 9.7.1 Yarn: 1.22.19 pnpm: 8.9.2 Relevant Packages: next: 14.0.3-canary.9 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
When I comment out either
AppNavLayoutDesktop
orAppNavLayoutMobile
incomponents/AppNavLayout.tsx
, the error no longer occurs. Additionally, completely removingapp/error.tsx
also prevents the error, and instead,not-found.tsx
is displayed as expected.NEXT-2095
The text was updated successfully, but these errors were encountered: