Skip to content

Instantly share code, notes, and snippets.

@berkeleycole
Created April 6, 2018 17:45
Show Gist options
  • Save berkeleycole/ddcd7bad2b9c422cacdffef51a48bbd1 to your computer and use it in GitHub Desktop.
Save berkeleycole/ddcd7bad2b9c422cacdffef51a48bbd1 to your computer and use it in GitHub Desktop.
Rules of React

Rules of React

  • Never update State directly, always use setState()
  • Never alter the dom directly, always operate on a value in state
  • Only call setState once per method or render cycle
  • State is for values that change, Props is for values that don't, constants should be set outside the component

For cleaner React

  • instead of using this.state multiple times, destructure the state object to save values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment