Q15: What are Custom Hooks and why would you write one?
Custom Hooks are JavaScript functions whose names start with use and can call other React hooks. They allow extracting reusable stateful logic out of components into isolated functions for sharing across the application.
Key Takeaways
- Custom hooks encapsulate reusable stateful behavior across components.
- Must follow Hook naming rules (
usePrefix) to allow static linting.
Knowledge Check
What naming convention MUST Custom Hooks follow in React?