QuizNot attempted
A derived boolean as a dependency
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- 2
- The dependency is the boolean
count > 3, which isfalsefor 0–3 andtruefor 4–6 - it changes only once (3→4), so the effect runs on mount and once more: 2.
- Not 1: the false→true flip re-runs it.
- Not 6 or 7: React compares the boolean, not
count, so other clicks don't change the deps. - (The lint rule would flag the expression, but the behaviour is well defined.)