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 Hooks flashcards as text
What is useState in React?
Answer: A hook that adds state to functional components, returning the current value and a function to update it
useState returns a pair: the current state value and a setter function. When the setter is called, the component re-renders with the new value.
What is useEffect used for?
Answer: Performing side effects like data fetching, subscriptions, or DOM manipulation after render
useEffect runs after render and handles side effects. The dependency array controls when it re-runs. Cleanup functions handle teardown.
What is the dependency array in useEffect?
Answer: An array of values that determines when the effect should re-run — changes trigger re-execution
The dependency array tells React which values to watch. Empty array = run once. No array = run every render. With values = run when those values change.
What is useContext?
Answer: A hook that accesses context values without wrapping components in Consumer, enabling shared state across the component tree
useContext provides a way to pass data through the component tree without prop drilling, accessing values from the nearest matching Context Provider.
What is useRef used for?
Answer: Creating a mutable reference that persists across renders without causing re-renders when changed
useRef creates a container for a mutable value that persists across renders. Common uses include accessing DOM elements and storing previous values.
What is useMemo?
Answer: A hook that memoizes expensive calculations, only recomputing when dependencies change
useMemo caches the result of an expensive computation and only recalculates when its dependencies change, preventing unnecessary recalculations on every render.
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