fix(server): Show/Switch should ignore zero-arg function children#2808
Merged
ryansolid merged 2 commits intoJul 1, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: a89bac5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
…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.
Co-authored-by: Cursor <[email protected]>
2053e7b to
a89bac5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the client,
Show/Switchonly 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 keyedwhenchanges. This is intentional per #1508. The server implementation inrendering.tsnever 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.ErrorBoundaryright next to it already does this correctly (f.lengthcheck), so it's just an inconsistency rather than deliberate.Fixed by mirroring the same
.length > 0check client-side uses (also matches how the 2.0 rewrite already does it innext, it just never got backported). Added tests inrendering.spec.tscovering both the zero-arg case and that real render-props still work for keyed/non-keyed.