3 ms·
The problem that hooks solve really nicely is when you want per-component state, but you duplicated versions of that state (and surrounding logic) in different
by nicoburns 3y ago
The problem that hooks solve really nicely is when you want per-component state, but you duplicated versions of that state (and surrounding logic) in different components. With class-based React components you had to use things like higher order components, or manually add the state properties into each component. With hooks this is all neatly abstracted away.
You don't always need this. Sometimes your business logic can just be a pure function. But where you do (and IME this is quite common), hooks are super nice.