Skip to content

Instantly share code, notes, and snippets.

@danieldogeanu
Last active March 9, 2020 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieldogeanu/483da90e91d0b08884d2230eb69115d2 to your computer and use it in GitHub Desktop.
Save danieldogeanu/483da90e91d0b08884d2230eb69115d2 to your computer and use it in GitHub Desktop.
React lifecycle methods in which is not allowed to set state.

Don't set state in the following methods or you'll create an infinite loop and your app will crash:

  • componentWillMount() // State doesn't exist yet.
  • render()
  • shouldComponentUpdate()
  • componentWillUpdate()
  • componentWillUnmount() // The component is going away.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment