Created
June 7, 2022 14:28
-
-
Save adityatyagi/02719fa662a89042a74d68c557a59a77 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
// App.js (parent component) | |
... | |
... | |
... | |
// this function is NOT re-created on ever re-execution of this function | |
const onDemoClick = useCallback(() => { | |
console.log("Demo click function invoked"); | |
}, []); | |
return ( | |
<div> | |
<h2>Virtual DOM demo by Aditya Tyagi</h2> | |
{/* the function onDemoClick will not be re-recreated every-time on re-exection of this parent. It will only be re-created when any of the params passed to dependency array changes. */} | |
<DemoOutput onClick={onDemoClick} show={false} /> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment