0.0.2 • Published 7 years ago
simple-reason-react v0.0.2
SimpleReasonReact
npm install --save simple-reason-reactSimpleReasonReact is a fork of ReasonReact adapted to work with Hooks, with Hooks types from Jared Forsyth.
Reason React uses the good old createClass under the hood. SimpleReasonReact has a simplified api that converts components defined in Reason to plain function components, allowing hooks to be used.
API
The api is similar to ReasonReact, but there's only one type of component, and you can only define a render function.
Example:
module Counter = {
let component = ReasonReact.component("Counter");
let make = (~initial=0, _children) => {
...component,
render: _self => {
let (count, setCount) = Hooks.useState(initial);
<div>
{ReasonReact.string(string_of_int(count))}
<button onClick={_ => setCount(. count + 1)}>
{ReasonReact.string("Click me")}
</button>
</div>;
},
};
};Status
Very early experimentation. Only for the brave, not for production. Some things are broken.
Let's chat on Discord!