Deprecated life cycle methods

There are a few life cycle methods that have been deprecated and renamed in React 17. We don't need to use these anymore—getDerivedStateFromProps and getSnapshotBeforeUpdate essentially replaced them. However, here's a brief description of these methods, in case you come across them in existing codebases:

  • componentWillMount (now UNSAFE_componentWillMount): This is called before the component is added to the DOM during an initial render
  • componentWillReceiveProps (now UNSAFE_componentWillReceiveProps): This is called when the component props change
  • componentWillUpdate (now UNSAFE_componentWillUpdate): This is called just before a component updates

Get Learn React with TypeScript 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.