A custom hook must start with the lowercase word use (e.g., useAuth, useWindowSize, useFetch):
React's ESLint plugin uses this naming prefix to automatically enforce the Rules of Hooks inside your custom function (ensuring hooks aren't called conditionally or in loops).
If you omit the use prefix, React will treat it as a standard function and will not warn you when hook violations occur.
3. Extracting a Window Dimensions Hook
Consider how multiple components (carousels, responsive charts, navigation drawers) need to know the browser's viewport width:
Without Custom Hook:
Every component duplicates 15 lines of useState, useEffect, and resize event listeners.
4. Do Components Using the Same Custom Hook Share State?
*No! Custom Hooks share stateful logic, NOT state itself!*
Each call to a custom hook creates a completely independent container of state. If Component A and Component B both call useWindowSize(), each component has its own private windowSize state in React's Fiber tree. (If you want components to share the exact same state instance, combine the custom hook with React Context).
Interactive Quiz• Knowledge Check
Practice Quiz
Question 1
What prefix must all custom React hooks begin with?
Question 2
Do two components that call the same custom hook share the exact same state values?
Question 3
What can a custom hook return?
Question 4
Which of the following is a primary architectural benefit of extracting custom hooks?
Question 5
Can a custom hook invoke other built-in React hooks like useState and useEffect?
Next Lesson
Building Practical Custom Hooks (useLocalStorage, useDebounce)
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.