Skip to content

Conversation

@jchavarri
Copy link
Contributor

@jchavarri jchavarri commented Aug 19, 2020

@rickyvetter The error raised when using spread with DOM elements prevents sharing components code that can be compiled with both tyxml and reason-react.

This error was useful when migrating from JSX2, but I hope ReasonReact users are not running into it these days as the spread operator has been mostly removed from JSX3 documentation, so I hope the change is ok.

This is an example of element that compiles fine with tyxml and succeeds after these change with ReasonReact as well:

module MyComponent = { [@react.component] let make = () => <a> ...{ Array.map( x => <li> x </li>, [| <a href="/foo"> {React.string("Foo")} </a>, <a href="/bar"> {React.string("Bar")} </a>, |], ) ->React.array } </a>; };
@jchavarri
Copy link
Contributor Author

Ah, wait, I see now that that this relies on createDOMElementVariadic, which would fail with map or other cases where children is not a literal, so this fix would need to somehow restore JSX2 behavior altogether 😞

@jchavarri jchavarri closed this Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant