React Lifecycle and Class Component Quiz
Four drills on legacy class lifecycle methods that still show up in interviews and codebases: mount/update/unmount, getSnapshotBeforeUpdate, setState batching, and getDerivedStateFromProps.
Question Bank
Medium
JavaScript
4 questions
quiz
react
interview-prep
design-patterns
158 views
1
List the three commit-phase lifecycle methods of a class component in order, plus what each one is used for. Show a <Clock> that starts and stops a timer.
What problem does getSnapshotBeforeUpdate solve that componentDidUpdate alone cannot? Show a chat-window example.
Why is setState asynchronous? What happens when you call this.setState({ count: this.state.count + 1 }) three times in a row inside a click handler?
What is the common mistake with getDerivedStateFromProps, and what should you usually do instead?
