February 2019
Beginner to intermediate
180 pages
4h 4m
English
ReasonReact supports the familiar ReactJS life cycle events. We will get a closer look at some of the life cycle events as we build our app, but, for now, let's see how we can implement ReactJS's componentDidMount life cycle hook for <App />:
let make = _children => { ...component, didMount: _self => Js.log("mounted"), render: _self => <div> {ReasonReact.string("hello")} </div>,};
Instead of componentDidMount, we use didMount. Again, didMount is just a field within a record returned by the component's make function. The type of didMount is self => unit, which is a function that accepts self and returns unit. Since it returns unit, it's likely that didMount causes a side effect, and in our example it does. Running this in the browser ...
Read now
Unlock full access