ReForm Next: new version of ReForm with hooks and custom multi type fields support with GADTs

Gabriel Rubens Abreu
Astrocoders
Published in
2 min readMay 30, 2019

ReForm Next is bringing three of the most wanted features:

  1. Type safe multi type values support;
  2. Type safe array fields (or nested forms if you look from another perspective);
  3. And a new React Hook API!

A quick look on how it looks like:

The new ReForm capabilities are just a thing because we could crack the right lenses API and GADTs usage internally to allow the multi-type interface (handleChange, getStateForField, etc.). If you want read more about GADTs I highly recommend this amazing interactive article https://sketch.sh/s/yH0MJiujNSiofDWOU85loX/. We would try to explain a bit here but the author of the article explained way better than I could.

If you want to see it in real action, we prepared two demos for you.
Take a look here. We have a demo with Reason Apollo Hooks and a demo of the array field interface.

What’s next

We are going to fine tune the validators API for more common usage ones so you don’t have to use Custom for everything. Probably also make usage of a Field component that can read the state from the context, useful when you need to scale a really complex form. PRs are welcome! https://github.com/Astrocoders/reform/projects/2.

None of this would have been possible without the content the Reason community is creating, specially this thread by Alex Fedoseev.

--

--