Higher order component for ReasonReact

A higher order component is basically a reusable component which allows you to takes in another component and return a new component.

To recap about higher component check our my older post here

In ReasoML higher order function are called “Functors” which takes in a module type and returns a module type, functors are written like function, except you use module instead of const/let/var…

lets try to write a simple functor here:

You can read read more about Functor here

So now we want to use this approach on higher order component, kind of like react, wrap component in a function, here wrap in a functor.