Skip to content

fix(props): assign ref before mounting children - #70

Merged
bigmistqke merged 1 commit into
solidjs-community:next-cleanupfrom
bigmistqke:fix/renderer-ref-timing
Jun 6, 2026
Merged

bigmistqke merged 1 commit into
solidjs-community:next-cleanupfrom
bigmistqke:fix/renderer-ref-timing

Conversation

@bigmistqke

Copy link
Copy Markdown
Contributor

useProps assigned an element's ref in a createRenderEffect that ran after useSceneGraph had already resolved and mounted the element's children. So a child reading the parent's ref in a reactive binding saw undefined on its first run and — since a plain let ref isn't reactive — never updated. This diverges from Solid DOM, which assigns refs before inserting children.

The fix moves the ref assignment ahead of useSceneGraph, so it lands before children mount.

Repro: a descendant binding that reads an ancestor's ref (e.g. a material color keyed off the parent mesh's ref) stays stuck at its initial value; the plain-Solid-DOM equivalent works.

Test: tests/core/ref-timing.test.tsx — "a child sees the parent's ref during its own render" (fails before, passes after).

useProps assigned the element's ref in a createRenderEffect that ran after useSceneGraph had already resolved and mounted the children. A child reading the parent's ref in a reactive binding therefore saw undefined on its first run and never updated — a divergence from Solid DOM, which assigns refs before inserting children.

Move the ref assignment ahead of useSceneGraph so it lands before children mount, and add a test covering a child that reads the parent's ref during its own render.
@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2026

Copy link
Copy Markdown

commit: fbd45d5

@bigmistqke
bigmistqke merged commit 98c8e80 into solidjs-community:next-cleanup Jun 6, 2026
2 checks passed
@bigmistqke
bigmistqke deleted the fix/renderer-ref-timing branch June 7, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant