DEV Community

Discussion on: Binding external components with ARIA properties in ReScript-React

yawaramin profile image
Yawar Amin

There's a neat little trick you can do to make a 'spread' component that just injects the given props objects into its child:

module Spread = {
  let make = (~props, ~children) =>
    ReasonReact.cloneElement(children, ~props, [||]);
<Spread props={"data-testid": "foo"}>
  <div />
johnridesabike profile image
John Jackson Author

This is a great trick! Thanks.