Created
October 8, 2021 17:17
-
-
Save clintonlunn/410e6db90866c5e2f9cff70a32e79afd to your computer and use it in GitHub Desktop.
Helpful useEffects Yo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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