Skip to content

Instantly share code, notes, and snippets.

@clintonlunn
Created October 8, 2021 17:17
Show Gist options
  • Save clintonlunn/410e6db90866c5e2f9cff70a32e79afd to your computer and use it in GitHub Desktop.
Save clintonlunn/410e6db90866c5e2f9cff70a32e79afd to your computer and use it in GitHub Desktop.
Helpful useEffects Yo
import { useEffect } from 'react';
// ...
const { var1, var2, var3 } = props
useEffect(() => {
console.log('tell me what loaded first time', { var1, var2, var3 })
}, [])
useEffect(() => {
console.log('tell me what changed plz ', { var1, var2, var3 })
})
/*
useEffect(() => { // cleanup yo use effects.
effect
return () => {
cleanup
}
}, [input])
*/
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment