2 ms·
Before hooks, it was really common to write container / component pairs. The wrapper would have to be a class component with state and lifecycle hooks, and the
by schwartzworld 6y ago
Before hooks, it was really common to write container / component pairs. The wrapper would have to be a class component with state and lifecycle hooks, and the inner component would only concern itself with presentation. IIRC, this was recommended in the react docs, although I've seen more than a few people misunderstand this pattern.
Hooks allow a way to abstract all that logic that used to require a component to house it. Components should still only really care about JSX, any logic more complex than an IF statement can live in functions or hooks.
- schwartzworld 6y agoI should also mention, you can access hooks in class components via HOCs. It's just one tiny extra step.