Custom hooks are React's composition model. They replace HOCs and render props with something far more elegant. Here's how to write them properly.
Rules of Hooks
- Only call hooks at the top level (not in loops, conditions, or nested functions)
- Only call hooks from React functions (components or other hooks)
- Custom hooks must start with "use"