React: Render boolean props set to false in source snippets#34968
Merged
Sidnioulz merged 1 commit intoMay 29, 2026
Conversation
Patches react-element-to-jsx-string (the @7rulnik fork) with algolia/react-element-to-jsx-string#733, which removes the branch that silently omitted boolean props explicitly set to `false`. React source snippets now render `foo={false}` instead of dropping the prop, while `true` props keep the shorthand syntax. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR patches the ChangesReact JSX Boolean Props Handling
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes ✨ Finishing Touches📝 Generate docstrings
Comment |
42 tasks
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.
Closes #27127
What I did
Patched
react-element-to-jsx-string(the@7rulnikfork we consume) with algolia/react-element-to-jsx-string#733.That PR removes the branch in
formatPropthat silently omitted boolean props explicitly set tofalsewhenuseBooleanShorthandSyntaxis enabled (the default). As a result, React auto-generated source snippets droppedfalseprops entirely — e.g.<Component disabled={false} />rendered as<Component />.After this patch:
falserenders asdisabled={false}.truekeeps the shorthand syntax (disabled), as before.This is one of the long-standing source-snippet bugs tracked in #33628.
Implementation notes
dist/esm/index.js+dist/cjs/index.js) with no separatesrc/formatProp.js, so the Yarn patch applies the equivalent change to both bundles.code/renderers/react/package.json(mirroring the existingreact-aria-componentspatch), sinceyarn patch-commitdoesn't auto-rewire npm-aliased dependencies.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Added a regression test in
jsxDecorator.test.tsx(should render boolean props set to false) that locks the new output. The full@storybook/reactrenderer suite (617 passed / 8 skipped) was re-run to confirm no existing source snapshot relied on the old false-omission behavior.Manual testing
yarn task --task sandbox --start-from auto --template react-vite/default-tsfalse, e.g.args: { disabled: false }.disabled={false}instead of omitting the prop. A prop set totrueshould still render as the shorthanddisabled.Note
This intentionally changes source-snippet output for any React story that passes an explicit
falseboolean prop, so docs/Chromatic snapshots for those stories will shift — that's the desired fix, not a regression.Documentation
No documentation changes needed — this restores expected behavior for an existing feature.
🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
falserender correctly.Chores