createUniqueId
returns duplicate IDs when used with <NoHydration>
and <Suspense>
#2452
Labels
enhancement
New feature or request
Milestone
Describe the bug
When rendering in SSR with
<NoHydration>
, a<Suspense>
wrapper will reset the context or counter used bycreateUniqueId
. This can result in duplicate IDs.Granted, there is no actual use case for
Suspense
without hydration. But when working with isomorphic JS, it is possible to introduce a component likeSuspense
into pure SSR code via shared components. For example, you might have a generic "Card" component that wraps everything inSuspense
with a default spinner as a matter of course. So long as no async resource is accessed within any of theSuspense
children on SSR, I would expect things to keep working as ifSuspense
wasn't there at all.Your Example Website or App
https://stackblitz.com/edit/solid-ssr-vite-kfrwzikw?file=src%2Fentry-server.tsx
Steps to Reproduce the Bug or Issue
Rendering something on the server like this will result in duplicate IDs.
Expected behavior
As a developer, I'd expect either:
Suspense
to effectively be a noop with hydration off and not reset thecreateUniqueId
contextSuspense
doesn't really do anything without hydration, for there to be some sort of warning or error.Screenshots or Videos
StackBlitz screenshot showing how IDs are unique with hydration on but not with hydration off:
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: