React Quiz
Test your React knowledge. — 8 questions
About the React Quiz
Test your React knowledge. This quiz has 8 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.
The questions follow the material in the React Fundamentals guide and the React cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.
Questions in this quiz
Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.
1. Which hook manages local component state in React?
Show answer
Answer: C. useState
useState returns [value, setter]. Calling the setter updates state and triggers a re-render.
2. When does useEffect with an empty dependency array [] run?
Show answer
Answer: C. Only once after the first render
[] means no dependencies — the effect runs once after the initial mount, similar to componentDidMount.
3. How are props passed to a child component?
Show answer
Answer: C. As attributes in JSX
Props are passed as JSX attributes: <Child name="Alice" />. They are read-only inside the child component.
4. What is the key prop used for in React lists?
Show answer
Answer: C. Helping React identify changed items for efficient re-rendering
Keys must be stable and unique among siblings. They help React match elements during reconciliation.
5. What does React.Fragment (or <>) do?
Show answer
Answer: B. Renders children without adding an extra DOM node
Fragment lets you return multiple elements without a wrapper div, keeping the rendered DOM clean.
6. How should state be updated in React?
Show answer
Answer: C. Call the setter function from useState
Direct mutation does not trigger re-renders. Always call the setter returned by useState.
7. What does the useMemo hook do?
Show answer
Answer: C. Caches an expensive computed value, recomputing only when deps change
useMemo(() => expensiveCalc(), [dep]) avoids re-running the expensive function on every render.
8. What does JSX compile to?
Show answer
Answer: C. React.createElement() calls
Babel transforms JSX into React.createElement(type, props, ...children) calls that build the virtual DOM tree.
How to use this quiz
- Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
- Note the questions you missed and revisit the matching section of the guide or cheatsheet.
- Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.