Skip to content

Instantly share code, notes, and snippets.

@heron2014
Created December 1, 2020 13:31
Show Gist options
  • Save heron2014/7636fdf040d461510c56e21765e36304 to your computer and use it in GitHub Desktop.
Save heron2014/7636fdf040d461510c56e21765e36304 to your computer and use it in GitHub Desktop.
useEffect componentDidMount
// Class
componentDidMount() {
console.log('Run me only when the component is first rendered/mounted');
}
// Hooks
useEffect(() => {
console.log('Run this arrow function only when the component is first rendered/mounted');
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment