What is a custom hook?

React refs, context and custom hooks · Freshers

Model answer

A custom hook is a function whose name starts with "use" and that calls other hooks, so you can reuse stateful logic between components. For example useLocalStorage(key) or useDebounce(value, delay).

It shares logic, not state: each component calling the hook gets its own separate state.

Learn this topic

React Context API Explained: Share Data Without Passing Props in the course React.js Full Course: Beginner to Advanced.

Sign in to add your own answer.

More questions