mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
3d9564215c
The original example fails to compile on my windows machine but updating bs-platform fixes that. Depending on bs-next causes example to fail (package compiled with old incompatible version of bs-platform) so I have included it in a bindings directory where it can serve as an example of reason bindings. Sources have been migrated to the latest reason-react.
23 lines
508 B
ReasonML
23 lines
508 B
ReasonML
type action =
|
|
| Add;
|
|
|
|
let component = ReasonReact.reducerComponent("Counter");
|
|
|
|
let make = (_children) => {
|
|
...component,
|
|
initialState: () => 0,
|
|
reducer: (action, state) =>
|
|
switch action {
|
|
| Add => ReasonReact.Update(state + 1)
|
|
},
|
|
render: (self) => {
|
|
let countMsg = "Count: " ++ string_of_int(self.state);
|
|
<div>
|
|
<p> (ReasonReact.string(countMsg)) </p>
|
|
<button onClick=(_event => self.send(Add))>
|
|
(ReasonReact.string("Add"))
|
|
</button>
|
|
</div>
|
|
}
|
|
};
|