Custom Hooks Flashcards
6 cards from real React practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Custom Hooks flashcards as text
What naming convention must all custom hooks follow?
Answer: They must start with 'use'
Custom hooks must start with 'use' so React's linter can enforce the Rules of Hooks for them.
What is the main benefit of extracting logic into a custom hook?
Answer: Reusing stateful logic across multiple components without duplicating code
Custom hooks let you extract and share stateful logic (state, effects, subscriptions) across components cleanly.
Can two components using the same custom hook share state?
Answer: No, each component gets its own isolated state instance
Each component that calls a custom hook gets its own isolated copy of the hook's state and effects.
Which of the following can a custom hook contain?
Answer: Any combination of built-in hooks and logic
A custom hook is just a JavaScript function that can call any built-in or custom hooks internally.
Where can a custom hook be called from?
Answer: Inside function components or other custom hooks
Hooks (including custom ones) can only be called at the top level of function components or other hooks.
What does a custom hook typically return?
Answer: It can return anything: values, functions, arrays, objects, or nothing
Custom hooks have no restrictions on their return value; they can return whatever their consumers need.
Written and edited by Nathan Beja, founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy