-
Notifications
You must be signed in to change notification settings - Fork 401
Open
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
Hydration fails if you read element prop outside JSX like
const BrokenTest = (p: { children?: JSXElement }) => {
console.log(p.children);
return <div/>;
};
or more than once like p.children && <div>{p.children}</div> or <Show ...> equivalent
However, if you use a pipe or IIFE where underlying component reads the (jsx.element) signal only once inside template, it works.
Example:
(() => {
const el = p.children;
return <div>{el && <div>{el}</div>}</div>
})()
or
{pipe(p.children, el => el && <div>{el}</div>}
I'm guessing SolidJs creates a hydration key on each read action and then fails to find it inside the DOM.
Another thing to note:
- this seems to cause issues when passed children contains an html element (
<div>hi</div>), but not if i just pass a string by itself
Expected behavior 🤔
hydration should work in all those cases
Steps to reproduce 🕹
stackblitz: https://codesandbox.io/p/devbox/423f4v
select any "not working" option and refresh the demo window -> see hydration error
Short example:
...
<Route href="/" component={() => <BrokenTest><div>boom</div></BrokenTest>} />
...
const BrokenTest = (p: { children?: JSXElement }) => {
console.log(p.children);
return <div/>;
}
// OR
const BrokenTest = (p: { children?: JSXElement }) => {
return <div>{p.children && <div>{p.children}</div>}</div>
}
Context 🔦
No response
Your environment 🌎
all latest:
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.15.3",
"@solidjs/start": "^1.2.0",
"solid-js": "^1.9.9",Metadata
Metadata
Assignees
Labels
No labels