Skip to content

Fix multi-child fragment#852

Merged
jchavarri merged 4 commits intomainfrom
fix-multichild-fragment
Aug 16, 2024
Merged

Fix multi-child fragment#852
jchavarri merged 4 commits intomainfrom
fix-multichild-fragment

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

@tatchi
Copy link
Contributor

tatchi commented Aug 15, 2024

Nice, thanks! 🤗

@anmonteiro anmonteiro force-pushed the fix-multichild-fragment branch from 90ee9f8 to 5f83a0d Compare August 16, 2024 03:15
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
@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)
davesnx added a commit that referenced this pull request Nov 18, 2024
* 'main' of github.com:/reasonml/reason-react:
  fix: type of pipeable stream to allow objects with keys (#854)
  reason-react-ppx: + lower bound in ocaml
  add missing entries to changelog
  Fix multi-child fragment (#852)
  update compiler version in makefile cmd (#851)
  Add locations-check test (#844)
  fix: re-enable failing tests + fix location tests (#850)
  test: repro #840 (#842)
  Add CSS Box Alignment Module Level 3 (#847)
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