React HooksLesson 54Free preview
React Custom Hooks
This lesson is part of React · All levels
Summary
Custom Hook is a common JavaScript function that calls other Hooks in, so that repeating logic can be reused in many components. A custom hook can return multiple values at once in the form of an array or object. Because it's a function, the states in it stay separate for each caller.
Key points
- The name must be prefixed to use to enforce Hooks' rules.
- You can call the other Hooks in.
- Returns the state or function required by the caller
- Logic is tested and reusable between components.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.