Skip to content

Conversation

@jchavarri
Copy link
Collaborator

@jchavarri jchavarri commented Apr 18, 2025

Reverts #823.

A user complained in Discord:

I am currently trying to use the current main branch of reason-react with the new React 19 changes.
Is it intended, that it is no longer possible to have multiple children in a custom react component without a fragment?

module MyComponent = {
  [@react.component]
  let make = (~children) => {
    <section> children </section>;
  };
};

<MyComponent>
  <div> {React.string("child1")} </div>
  <div> {React.string("child2")} </div>
</MyComponent>;

This is throwing the error

Error: This expression has type < children : React.element array > Js.t
       but an expression was expected of type
         < children : React.element > Js.t
       The method children has type React.element array,
       but the expected method type was React.element

To fix this error you have to wrap the two div in a fragment (<>...</>).
I guess is coming from this change? #823

I talked to @davesnx online and while we could do some introspection in the ppx to start branching off generated code depending on the kind of children (element vs something else) it seems too much magic for the upsides.

@jchavarri jchavarri marked this pull request as ready for review April 18, 2025 15:11
@jchavarri jchavarri requested review from anmonteiro and davesnx April 18, 2025 15:11
@davesnx davesnx merged commit 77b1bfb into main Apr 18, 2025
3 checks passed
davesnx added a commit that referenced this pull request Jun 4, 2025
…-5-support

* 'main' of github.com:/reasonml/reason-react:
  feat(react-dom): add experimental module (#849)
  add color to domProps (#871)
  Remove most React.Uncurried from tests (but keep 1) (#890)
  fix melange dep
  Revert support for "custom children" in uppercase components (#891)
  ci: update nix action (#888)
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.

3 participants