Hooked on components - 401-advanced-javascript-aimurphy/seattle-javascript-401n13 GitHub Wiki
Hooks let us organize the logic inside a component into reusable isolated units, solving problems such as:
- Huge components that are hard to refactor and test
- Duplicated logic between different components and lifecycle methods
- Complex patterns like render props and higher-order components
Ground rules:
Although they are functions YOU MUST NEVER:
- call Hooks inside loops, conditions, or nested functions--top level ONLY!
- call Hooks from regular JavaScript functions. Only call Hooks from React function components!