-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
First layout not working on Next.js 14.2.23 - react-dom.development.js:17497 Uncaught Error: Element type #165
Comments
Can you check whether its related to uikit or r3f in general by removing the uikit elements and just adding a simple ? |
It is uikit related. The tests I did:
The crazy thing is that the page actually displays the components correctly, but there is the uncaught error. Next.js sometimes throws hydration warnings that, in this context, are not a problem since I am actively doing everything on the client. But they’re just warnings. This is an actual error though. I tried putting it inside its own I tried rendering it conditionally by having an const [isActive, setIsActive] = useState(false);
return (
<Canvas onPointerDown={() => setIsActive(true)}>
{isActive ?
<Root>
…
</Root>
: null}
</Root>
</Canvas>
) But it also threw the error even before the component was rendered. When clicking the canvas the content shows up properly. |
I am not really an expert on nextjs so I have no intuition here. I'd recommend sharing a repo, so I can check your setup myself |
While creating the repo I found where the issue is happening. TL;DR: the error is thrown when the UI component is inside a The structure of the page where I am displaying the content is: <section>
<Suspense>
<Canvas>
<UiComponent />
</Canvas>
</Suspense>
</section> This structure is divided in two: So the division is: <section>
<Suspense>
//// server ////
//// client ////
<Canvas>
<UiComponent />
</Canvas>
//// client ////
//// server ////
</Suspense>
</section> In this setup a hydration error is thrown. However, if the suspense is moved into the client component, it works. <section>
//// server ////
//// client ////
<Suspense> // suspense in the client component
<Canvas>
<UiComponent />
</Canvas>
</Suspense>
//// client ////
//// server ////
</section> As for why this happens, I have no idea. And still I was not being able to reproduce the solution in my project. It turns out that Next.js has an application-wide suspense boundary if you create a component in the I created a repo with code to reproduce the error happening in the two ways I described above as well as the expected behavior. In the It is very, very specific, so if my explanation wasn't very good please tell me so I can try and elaborate on whatever's not clear. |
My project uses libraries that are not ready for React 19, therefore I am using React 18, Next.js v. 14.2.23, React Three Fiber 8.17.10, and React Three uikit 0.8.4.
When trying to reproduce the first layout example
I get the following error:
The component is a client component with
"use client";
.The problem still occurs in a brand new Next project.
What am I doing wrong?
The text was updated successfully, but these errors were encountered: