Ian Wilson's Spirits and Such Dev Newsletter

Subscribe
Archives
April 15, 2019

Reason React - now with Hooks!

ReasonML is a programming language that combines the simplicity of JavaScript with the performance of OCaml. JavaScript programmers should give ReasonML a try. Reason inherits OCaml’s type system as well as the approachability of JavaScript.

With ReasonReact and BuckleScript, we can compile Reason code to JavaScript that works like good old React.

But that’s not all, things are getting even better for the Reason ecosystem. Earlier last week, ReasonReact version 0.7.0 dropped, with support for React hooks. We can now build robust components with React hooks that:

  • eliminate duplicated lifecycle logic (like in componentDidMount, componentDidUpdate, and componentWillUnmount)
  • eliminate the need for complicated patterns like higher-order components or render props
  • allow easier refactoring of stateful components

Think for a moment about that last point, what else give us easier refactorability?

A rock solid type system and a helpful compiler!

I spent much of Saturday morning blasting through a new tutorial that aims to make getting a handle on the new syntax of React with Reason.

When vanilla React hooks were announced in November 2018, I was fired up. But, I still wanted to build new projects with ReasonML. I had to wait, but the wait was worth it.

If you can spare some time, give the article a look see. Check out ReasonML with React Hooks Tutorial — Building a Pomodoro Timer.

Don't miss what's next. Subscribe to Ian Wilson's Spirits and Such Dev Newsletter:
This email brought to you by Buttondown, the easiest way to start and grow your newsletter.