Render Props
Basic Render Props
[@react.component]
let make = () => {
<Loader render={() => <div />} />
};
/* Loader.re */
[@react.component]
let make = (~render) => {
<div> {render()} </div>
};
Children as Render Props
[@react.component]
let make = (~children) => {
<Loader>
{person => <div> {React.string(person.name)} </div>}
</Loader>;
};
/* Loader.re */
[@react.component]
let make = (~children) => {
let person = {name: "Peter"};
<div> {children(person)} </div>;
};