React · Junior · Question 29 of 75
Why must a custom hook's name start with use?
- 1Otherwise the bundler can't export it from the module
- ✓Correct answer: That's how the linter and React know it contains hooks
- 3The
useprefix enables automatic memoization of the result
Explanation
The use prefix is a convention that eslint-plugin-react-hooks and the React Compiler rely on. By itself it doesn't memoize anything. A function with no hooks inside shouldn't be named use... - it's a regular utility.