Skip to content

fix(server): Show/Switch should ignore zero-arg function children#2808

Merged
ryansolid merged 2 commits into
solidjs:mainfrom
chatman-media:fix/ssr-show-switch-zero-arg-children
Jul 1, 2026
Merged

fix(server): Show/Switch should ignore zero-arg function children#2808
ryansolid merged 2 commits into
solidjs:mainfrom
chatman-media:fix/ssr-show-switch-zero-arg-children

Conversation

@chatman-media

@chatman-media chatman-media commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

On the client, Show/Switch only treat a function child as a render-prop if it actually takes an argument (child.length > 0) -- a zero-arg function is just a static value, not re-invoked when the keyed when changes. This is intentional per #1508. The server implementation in rendering.ts never had that gate, so it calls any function unconditionally, which means SSR output can diverge from what the client would do with the same JSX. ErrorBoundary right next to it already does this correctly (f.length check), so it's just an inconsistency rather than deliberate.

Fixed by mirroring the same .length > 0 check client-side uses (also matches how the 2.0 rewrite already does it in next, it just never got backported). Added tests in rendering.spec.ts covering both the zero-arg case and that real render-props still work for keyed/non-keyed.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a89bac5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

chatman-media and others added 2 commits July 1, 2026 13:23
…e the client does

Server-side Show/Switch called any function child unconditionally, but the
client only treats it as a render-prop when it actually takes an argument
(see solidjs#1508) -- a zero-arg function child is just a static value. This made
SSR output diverge from what the client would produce for that case.
ErrorBoundary already gets this right (f.length check), Show/Switch didn't.
@ryansolid ryansolid force-pushed the fix/ssr-show-switch-zero-arg-children branch from 2053e7b to a89bac5 Compare July 1, 2026 20:25
@ryansolid ryansolid merged commit 0d92d48 into solidjs:main Jul 1, 2026
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.

2 participants