reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.14k stars 428 forks source link

Support for props spread #2570

Open rickyvetter opened 4 years ago

rickyvetter commented 4 years ago

Support for this syntax would be helpful for ReasonReact:

<div {...props} />

Conceptually it maps to a component whose total set of props has been created elsewhere. I'd propose that it could desugar to:

let _ = ((div props)[@JSX ])

Importantly - I don't think that it's useful or interesting (for the purposes of ReasonReact at least) to support props spread+individual props. I am not asking for support for either of:

<div {...props} somethingElse=1 />;

<div {...props}> somethingElse </div>

For context on why I want this - today RR components are a set of two functions - x and xProps in the same module scope. Sometimes folks want to (or can only) make a component which is just x. This syntax allows them to do so and get the props through any means that they'd like while still being able to use JSX.