-
-
Save Eliav2/00f3a6d57ac048358c3a81cca659a088 to your computer and use it in GitHub Desktop.
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
const Basic = () => { | |
// log function helper | |
// this will help up follow the component phase cycle | |
const render = useRef(0); | |
const call = useRef(0); | |
const consoleState = () => `{call:${call.current},render:${render.current}}`; | |
const log = (...args) => console.log(...args, consoleState()); | |
// update phase counts | |
call.current += 1; | |
useEffect(() => { | |
render.current += 1; | |
}); | |
//logic | |
useEffect(() => { | |
log('mount has finished'); | |
}, []); | |
useEffect(() => { | |
log('render has finished'); | |
}); | |
log('update call'); | |
return <div/>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment