EduFlow
React Fundamentals

Checkpoint: State & Events

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

A “+1 later” button runs setTimeout(() => setCount(count + 1), 1000). You click it three times within a second. count was 0. What is it after the timers fire?

Question 2 of 5

handleRemove does const i = movies.findIndex((m) => m.id === id); movies.splice(i, 1); setMovies(movies);. The movie does not disappear. Why?

Question 3 of 5

You click Add, the new movie appears for a moment, then the page reloads and it is gone. What is missing?

Question 4 of 5

This timer counts up by 2 every second in development. What is the fix?

JSX
useEffect(() => {
  setInterval(() => setSeconds((s) => s + 1), 1000);
}, []);
Question 5 of 5

SearchBox keeps query in its own state. MovieList, its sibling, must show only movies whose title contains the query. What do you do?

5 questions unanswered