DEV Community


Discussion on: Learning ReasonReact Step by Step Part: 3

theodesp profile image
Theofanis Despoudis

I'm beginning to lose you. I just don't understand why someone will use Reason when something simple such as merging two objects or getting the value of the event target gets "Un-Reasonable" complicated in the end?

sophiabrandt profile image
Sophia Brandt Author

Good question.
Updating the state in a reducer works the same in React though. If you mutate an object you hold in useState or useReducer with Javascript, you'll get a bug, too.
JavaScript allowing for dynamic values in objects is nice and easy for a developer but it's not type-safe and AFAIK also bad for the compiler as it cannot optimize before execution, as the object is like a "black box".
I'm not sure how Typescript handles that, but if you define an interface for the object, you are bound to those limitations, too.
But ReasonML has a lot of warts, one of them Javascript interoperability.
This blog post series is not my goal to sell you ReasonML or ReasonReact, but my exploration of creating an app.
I actually like the type safety, but I'm not sure if you couldn't have the same experience with Typescript.