reason-react-brunch
Version:
React bindings for Reason, modified to work with brunch and bucklescript
30 lines (21 loc) • 715 B
Markdown
title: Simple
See https://github.com/reasonml-community/reason-react-example for examples you can clone and run. This page copy pastes a few from there for ease of reading.
```reason
let component = ReasonReact.statelessComponent("Page");
let handleClick = (_event, _self) => Js.log("clicked!");
let make = (~message, _children) => {
...component,
render: self =>
<div onClick={self.handle(handleClick)}>{ReasonReact.string(message)}</div>
};
```
Usage in another file:
```reason
ReactDOMRe.renderToElementWithId(<Page message="Hello!" />, "index");
```
In the same file, you'd do:
```reason
ReactDOMRe.renderToElementWithId(ReasonReact.element(make(~message="Hello!", [||])), "index");
```