February 2019
Beginner to intermediate
180 pages
4h 4m
English
In our render function, we can attach event listeners to DOM elements the same way that we would in ReactJS. For example, to listen for the click event, we add an onClick attribute and set its value to an event handler:
let component = ReasonReact.statelessComponent("App");let make = _children => { ...component, render: _self => <div onClick={_event => Js.log("clicked")}> {ReasonReact.string("hello world")} </div>,};
However, this callback function must accept exactly one argument (corresponding to a JavaScript DOM event) and must return a type called unit.
Read now
Unlock full access