Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-child fragment #852

Merged
merged 4 commits into from
Aug 16, 2024
Merged

Fix multi-child fragment #852

merged 4 commits into from
Aug 16, 2024

Conversation

jchavarri
Copy link
Collaborator

Currently, this code <> <div/> <div/> </> will trigger the infamous warning: Each child in a list should have a unique "key" prop.

This PR modifies the expression switch for fragments so that those with 0 or 1 child use jsx and those with 2 or more children use jsxs.

Copy link
Member

@davesnx davesnx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix

.ocamlformat Outdated Show resolved Hide resolved
@tatchi
Copy link
Contributor

tatchi commented Aug 15, 2024

Nice, thanks! 🤗

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a small refactor that avoids duplicating the code in the entire branch (just decides between jsx and jsxs)

@jchavarri jchavarri merged commit 8d6b326 into main Aug 16, 2024
3 checks passed
@jchavarri jchavarri deleted the fix-multichild-fragment branch August 16, 2024 06:21
jchavarri added a commit to jchavarri/opam-repository that referenced this pull request Aug 19, 2024
CHANGES:

* Add `isValidElement` (@r17x in
  reasonml/reason-react#837)
* Add `startTransition` (@r17x in
  reasonml/reason-react#838)
* Convert `ReasonReactErrorBoundary` to Reason instead of `%raw` JS. This has
  the benefit of skipping a hardcoded `require('react')` call (@anmonteiro in
  [reasonml/reason-react#839](reasonml/reason-react#839))
* Add CSS Box Alignment Module Level 3 (@davesnx in
  reasonml/reason-react#847)
* Fix: Remove "unique `key` prop" warnings from multi-child fragment elements
  (@jchavarri in reasonml/reason-react#852)
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
CHANGES:

* Add `isValidElement` (@r17x in
  reasonml/reason-react#837)
* Add `startTransition` (@r17x in
  reasonml/reason-react#838)
* Convert `ReasonReactErrorBoundary` to Reason instead of `%raw` JS. This has
  the benefit of skipping a hardcoded `require('react')` call (@anmonteiro in
  [reasonml/reason-react#839](reasonml/reason-react#839))
* Add CSS Box Alignment Module Level 3 (@davesnx in
  reasonml/reason-react#847)
* Fix: Remove "unique `key` prop" warnings from multi-child fragment elements
  (@jchavarri in reasonml/reason-react#852)
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.

4 participants