refactor: remove unnecessary Fragment wrapping#110
Open
TrevorBurnham wants to merge 1 commit into
Open
Conversation
TrevorBurnham
requested review from
johannes-weber
and removed request for
a team
January 24, 2026 23:58
pan-kot
requested changes
Jul 22, 2026
pan-kot
left a comment
Member
There was a problem hiding this comment.
The changes conflict with main.
Children.only() already validates that the highlight result is a single element, so wrapping it in a Fragment first just to read .props.children back off the wrapper is a no-op. Call Children.only() on the result directly and cast, since the highlight prop is typed as ReactNode.
TrevorBurnham
force-pushed
the
refactor/remove-fragment-wrapping
branch
from
July 26, 2026 19:08
ae09dde to
7d0cb1a
Compare
Contributor
Author
|
@pan-kot Updated! |
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.
Description
Children.only()already validates that thehighlightresult is a single element. Wrapping that result in aFragmentfirst, only to read.props.childrenback off the wrapper, is a no-op:The
Children.only()call is kept deliberately.CodeViewProps.highlightis typed(code: string) => React.ReactNode, so a consumer can return a string, an array, or a fragment.Children.only()turns those cases into a clear error rather than silently rendering nothing when the render path readscodeElement.props.children. The old code got itsReactElementtyping implicitly from the Fragment wrapper, so the explicit cast replaces that.No behavior change.
How has this been tested?
Existing unit tests pass (51 tests). Type-checked, linted, and verified in the dev server that the demos render unchanged.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.