← React Beginner Questions - Set 9 Q85

What are React lifecycle methods?

React Beginner Questions - Set 9

Example

class Data extends Component {
  componentDidMount() { this.load(); }              // after first render
  componentDidUpdate(prev) { if (prev.id !== this.props.id) this.load(); }
  componentWillUnmount() { this.abort(); }          // cleanup
  render() { return null; }
}

What to notice

← Back to the question list