
Dilemmas with React Hooks – Part 1: States and Reducers - liorgut
https://yearn2learn.netlify.com/dilemmas-with-react-hooks-1
======
bfrydl
> However, a major drawback of this method is the lack of descriptiveness.
> When you see the dispatch function in your props, you don’t know the actions
> that you can invoke and you need to make reverse engineering. It would be
> avoided if we had passed each callback directly as a prop.

It's worth mentioning that if you use TypeScript, it is possible to strongly
type your dispatch function to only accept valid actions. In fact TS is smart
enough to type check the individual properties of different actions based on
the string value of the `type` property.

You can use that with the new React Context API mentioned at the end of the
article to build yourself a strongly-typed, self-contained mini redux and
react-redux alternative.

------
pier25
I haven't used hooks yet, but AFAIK the idea was to simplify the use of
classes to functional components.

Although this article shows that hooks have greater implications than that.
Also while maybe less verbose than classes, the code seems much more difficult
to follow.

~~~
chrisco255
I thought this at first too, but after using it in practice, it's very simple.
One of my favorite things about Functional components is how effortless they
are to create. Since they're effortless, you tend to break up your components
into much more modular pieces. And I notice that my code base overall is much
cleaner to look at and work with.

------
nudelx
Very nice !!!

