-
Notifications
You must be signed in to change notification settings - Fork 375
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
[Bug?]: Hydration Mismatch for passed JSX elements #1568
Comments
Update: if i pass a function that returns JSXElement instead of JSXElement instead, it works
|
This is expected with current state of hydration. <Separate items={[<span>Hello</span>, <span>world</span>]} /> compiles to _$createComponent(Separate, {
get items() {
return [_tmpl$(), _tmpl$2()];
}
}) and accessing 👉 But new elements created while evaluating i() === p.items.length - 1 ? <>{item}</> : <>{item} • </> this doesn't happen with <Separate items={[() => <span>Hello</span>, () => <span>world</span>]} /> or /* 🛑 use at your own risk */
const items = [<span>Hello</span>, <span>world</span>]
<Separate items={items} /> // no getter or function Separate(p) {
/* ❌ don't do this */
const items = p.items // just for the sake of the point
const slightlyCorrect = createMemo(() => p.items)
/* ✅ do this */
const correct = children(() => p.items)
} |
@mdynnl how is this expected? From the DX point of view it doesn't make much sense and this behavior is not documented anywhere. |
why can't i generate a new elements and not append them to the DOM? Why can't they be hydrated as part of the javascript? |
Yeah.. this is hard in general. The code above would be not good even in a purely client side app.. recreating elements over and over again. I'm going to close this as a duplicate of the linked issue in Solid core repo. But in general don't do this. Use the |
Duplicates
Latest version
Current behavior 😯
When i pass jsx elements as a prop to my separation component I get hydration errors
Expected behavior 🤔
it should work without hydration errors "Hydration Mismatch. Unable to find DOM nodes for hydration key ..."
Steps to reproduce 🕹
Stackblitz link
Steps:
Context 🔦
error "Hydration Mismatch. Unable to find DOM nodes for hydration key: 0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-3-1-2"
Your environment 🌎
The text was updated successfully, but these errors were encountered: