|
|
|
|
|
by alfonsodev
2115 days ago
|
|
> React hooks are a mess, or at least code based around it tends to be. I've read a lot warnings about the pitfalls, and about hooks not doing what you think they are doing, but honestly, I haven't experience any of that, maybe because my use cases are so close to the documented ones, that I don't need to stretch the concept, and it just works as intended for me. Could it be, that as with many other programming patterns, some developers are using it as a silver bullet, and trying to solve everything with hooks? Otherwise I'm failing to understand, it would be useful to see examples as the mentioned above. |
|
> Should I use Hooks, classes, or a mix of both? [0]
> When you’re ready, we’d encourage you to start trying Hooks in new components you write. [snip]
> Do Hooks cover all use cases for classes? [1]
> Our goal is for Hooks to cover all use cases for classes as soon as possible. [snip]
The answer about higher-order components is a little more nuanced but does say hooks should replace most of them:
> Do Hooks replace render props and higher-order components? [2]
> Often, render props and higher-order components render only a single child. We think Hooks are a simpler way to serve this use case. There is still a place for both patterns (for example, a virtual scroller component might have a renderItem prop, or a visual container component might have its own DOM structure). But in most cases, Hooks will be sufficient and can help reduce nesting in your tree.
Learning enough about the React lifecycle to make simple apps was a big task, but it felt like a bounded one for my purposes. Learnings hooks seems... strangely open-ended. There's a small set of built-in hooks that do certain things, and if I need more I'm supposed to build new hooks out of the old ones, and that's supposed to be it. Except that it isn't, because if that's all there was to it, people wouldn't be having difficulty. I just wish the rest of the story was sketched out and bounded for me in some way so I could know what I was getting into.