Skip to content

Instantly share code, notes, and snippets.

@heron2014
Last active December 29, 2020 01:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heron2014/b2d03b8b7622a255a47c5082576c6982 to your computer and use it in GitHub Desktop.
Save heron2014/b2d03b8b7622a255a47c5082576c6982 to your computer and use it in GitHub Desktop.
Key takeaways for useEffect
useEffect(fn) // run function on every render
useEffect(fn, []) // run function only when the component is first rendered
useEffect(fn, [value]) //run function when component is first rendered and when the `value` changes
// Remember if you pass dependency(value) which is an object - React perform
// strict comparision using "===" of the first level properties and will not
// conduct comparisons deeper into the properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment