4 ms·
Hooks are not a new syntax for class components. All the lifecycle logic is recast as building blocks of your render logic. State, props and context become inpu
by kiliancs 7y ago
Hooks are not a new syntax for class components. All the lifecycle logic is recast as building blocks of your render logic. State, props and context become inputs you explicitly declare in the function, effects are explicitly linked to their dependencies, and in the end, with all the inputs in their current state there's your output. This makes it easier to understand how props, state, context and effects interact to produce the result, and makes it harder to make mistakes. It also simplifies complex scenarios and lets you encapsulate and reuse logic around all these building blocks.