Course contentsShow
← React
Lesson 982 of 2,39625. Custom HooksFree lesson

Why Custom Hooks Must Start with 'use'

Understand the technical reason React enforces the 'use' prefix and how it enables lint rules and internal tracking.

Why Custom Hooks Must Start with 'use'

You'll learn the technical reason React enforces the 'use' prefix and what it unlocks for both linting and React's internal behavior.

The Technical Requirement

React doesn't just suggest the use prefix for custom hooks—it requires it for correctness. When you name a function starting with use, you're making a promise: "This function calls hooks inside." React and its tooling use this naming convention as a signal to enforce the Rules of Hooks.

How React's Linter Uses the Prefix

The ESLint plugin for React (eslint-plugin-react-hooks) scans your code looking for functions that start with use. When it finds one, it automatically checks that:

  • All hook calls inside happen at the top level
  • No hooks are called conditionally
  • The dependency arrays are correct

Without the use prefix, the linter treats your function as a regular JavaScript function and won't enforce these rules. You could accidentally break the Rules of Hooks without any warning.

Why This Matters for Custom Hooks

When you extract logic like useToggle or useLocalStorage, those custom hooks internally call useState, useEffect, or other hooks. If you named them toggleLogic() or getLocalStorage(), the linter wouldn't know they contain hooks—and wouldn't stop you from calling them conditionally or in loops.

The use prefix is React's signal that says: "Treat this function like a hook. Apply all the rules. Track its calls in the hook chain."

The Contract

Think of the use prefix as a contract: by naming your function useSomething, you're telling React "I'm playing by hook rules inside this function," and React promises to track and validate it accordingly.

Key Takeaway: The use prefix isn't just convention—it's how React's linter and internal tracking identify functions that call hooks, enabling automatic rule enforcement and preventing subtle bugs.