DEV Community

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

Collapse
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 = {
  [@react.component]
  let make = (~props, ~children) =>
    ReasonReact.cloneElement(children, ~props, [||]);
};
...
<Spread props={"data-testid": "foo"}>
  <div />
</Spread>
Collapse
johnridesabike profile image
John Jackson Author

This is a great trick! Thanks.