-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Suspense rendering problems with Next.js #3501
Comments
I have some issues with NextJs too. When I try to build I get the error: Can't find preact/compat/client |
@alex289 yes, no build problems on my side |
@alex289 can you open a new issue for that? It seems like the error you're seeing is not related to the issue here. |
I think this issue presents itself because we stay in hydration mode where we don't patch missmatches in DOM-attributes as this is commonly seen as a bug between So DOM arrives from server as <h3 style={{ color: 'green' }}>Else</h3> then we switch to <h1 style={{ color: 'red' }}>Fallback</h1> We hydrate but don't patch the innerText nor the style, nor the nodeType. When the Suspense resolves we see that the DOM still remains the same on <h2 style={{ color: 'blue' }}>Content</h2> We yet again haven't patched any of the needed things, I think this is because of our deferred hydration tricks we use when we are revolving around Suspending boundaries because we stay in hydration mode even though we will have to patch the |
Is this type of client/server variance actually valid? React is likely destroying and recreating the tree here, which doesn't seem like a good point of reference for correctness. We could flip hydration-deferred subtrees into mutative hydration mode, but that's a performance drawback. |
Well I guess that's a valid point when SSR returns vastly different content but if we never escape deferred hydration mode and switch route this could occur as well right? i.e. different |
Coming back to this @developit I do think React warns for this and that Lighthouse gives you CLS for this because we are changing the SSR response. I think what they advice in React is to do
|
In general this is considered a hydration mismatch though as the SSR'd result will be different from the client result at all times. This is present in React as well as Preact, referring to #4442 for explanations. Basically you'd have to have a isHydrated check rather than isClient. |
Using Next.js (SSR) -> package.json:
Describe the bug
Note the different html elements, styles applied on them and how they get rendered. The
Content
component just does a SWR api call with 2s sleep so suspense can get triggered.isClient
is used to use suspense once on the client since (afaik) Suspense does not work on the server.Let's say I have the following content on the page:
Bugs
Expected behavior
Suspense should work as expected: should render the fallback & should re-render(?) the consuming component once the suspended request is finished.
The text was updated successfully, but these errors were encountered: