February 2019
Beginner to intermediate
180 pages
4h 4m
English
The last argument to the make function is always the children prop—it's mandatory. Just like other props, children can be any data structure. As long as the component allows it, we can use the render prop pattern that is popular in ReactJS. Importantly, ReasonReact always wraps children in an array, so we need to unwrap the array with the ... syntax if we don't want this wrapping.
In App.re, we'll remove all props except for the required children prop. In the render function, we invoke children with our hardcoded greeting:
/* App.re */let component = ReasonReact.statelessComponent("App");let make = children => { ...component, render: _self => children("hello"),};
And in Index.re, we add a function as a child of <App /> that accepts ...
Read now
Unlock full access