React mock tests
Test yourself on the whole course, against the clock: questions from every module, then coding problems you solve and run right here. Your score comes at the end, with every answer explained.
Each mock test has 12 questions drawn from the lessons, and 45 minutes on the clock, which keeps running if you reload. Questions are worth a point each. Score 60% or more to pass; your best score is kept.
- 01Mock test 112 questions · 45 minutes · 12 points
- 02Mock test 212 questions · 45 minutes · 12 points
Part A · 12 questions
- Why call e.preventDefault() in a form's onSubmit handler?
- Clicking a button calls setCount(count + 1) three times in a row, with count at 0. What is count afterwards?
- How do you remove the item with a given id from a todos array in state?
- When does useEffect(() => {...}, []) run?
- Two components call the same custom hook. Do they share its state?
- Which attribute sets a CSS class in JSX?
- What makes an input "controlled" in React?
- How does a child ask its parent to change lifted state?
- Why does the temperature converter store only one temperature?
- What is the function returned from an effect for?
- Why must component names start with a capital letter?
- How do you return two sibling elements from a component?
Part A · 12 questions
- items is an empty array. What does {items.length && <List />} render?
- Why can't you write if inside JSX braces, as in {if (x) ...}?
- What should a component return to render nothing?
- Which prop reflects a checkbox's state?
- Why must hooks never be called inside an if statement?
- How do you use a component called Card inside another component?
- What goes inside {} in JSX?
- Why is items.push(newItem) wrong for updating state?
- Two sibling components need the same piece of state. Where should it live?
- An effect uses the value query. What should its dependency array contain?
- How do you call remove(id) when a button is clicked?
- What does setForm({ ...form, [name]: value }) do?