Utilitary containers for ReasonReact
npm install re-containers
Type safe high order components for ReasonReact
```
$ yarn add re-containers
Inspired by recompose, react-powerplug and smalldots
Available API
`ocaml
let%Epitath myState = c =>
let%Epitath mutate = c =>
myState.send(foo)
`
We recommend you reading this article to get started
`ocaml
module WithState = ReContainers.WithState.Make({
type state = int;
});
ReasonReact.string("Count is " ++ string_of_int(state))
Component
Nice for lifecycle helpers
`ocaml
...((self) => {
})
`Loader
Handling promises
`ocaml
module ReLoader = ReContainers.Loader.Make({
/ Promise result /
type t = int;
});
``ocaml
/ Could be a fetch for instance /
let makeTimeout = () =>
Js.Promise.make((~resolve, ~reject as _) =>
Js.Global.setTimeout(() => resolve(. 0), 2000) |> ignore
);
...(
({state, load}) =>

(ReasonReact.string(message))
(
switch (state) {
| Loading =>
(ReasonReact.string("Hang a sec"))
| Error(string) => (ReasonReact.string(string))
| Success(_promiseResult) => (ReasonReact.string("All good"))
| Empty => ReasonReact.null
}
)
)
`ReList
It manages the state of lists for you
Make
`ocaml
module ReList = ReContainers.ReList.Make({
type t = { name: string, age: int };
});
`Usage
`ocaml
...(({ list, pull, push }) => (
push(values)) /> (
list
|> List.map(todo => (
char.name == name && char.age == age)>
(ReasonReact.string(char.name))
))
|> Array.of_list
|> ReasonReact.array
)
))
``