`resize-observer@4.0.0-next.3` causes hydration mismatch
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start in packages/resize-observer/src/index.ts around line 201, where createEffect is gated by isServer. Compare server and client hydration behavior using the provided ElementSizeHydrationRepro component. Done means the resize observer no longer causes a hydration mismatch while preserving the intended size behavior; the Solid2 behavior discussion may require separate clarification.
Written by the indexing model from the issue text.
Description
Describe the bug
import { createSignal } from "solid-js";
import { createElementSize } from "@solid-primitives/resize-observer";
export default function ElementSizeHydrationRepro() {
const [target, setTarget] = createSignal<HTMLDivElement>();
const size = createElementSize(target);
return <><div ref={setTarget}>Width: </div>{size.width ?? "waiting"}</>;
}
The cause is that createEffect advances hydration id but it's only created on the client:
A workaround would be wrapping the use site in a new owner. A proper fix would be always createEffect regardless of isServer or not.
BTW, I believe that the idiomatic Solid2 way of writing this would be creating a writable signal with ssrSource: "client". This way the returned size can be non-null, but the result must be wrapped in a separate <Loading> boundary or else the component could never render due to the loop render -> get size -> observed el not mounted until rendered -> isPending, abort render. It sounds problematic at first but it actually prevents the render loop of using the size inside the measured element. However, that's a behavior change and needs discussion.
Minimal Reproduction Link
stack blitz pnpm is too old to run the new template
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 162
- Avg merge
- 19h 40m
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solidjs-community/solid-primitives
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
solidjs-community/solid-primitives#1000 · 3 comments · 5 reactions ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
solidjs-community/solid-primitives#830 · 2 comments ·
All issues in solidjs-community/solid-primitives
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·