Created
June 7, 2022 14:27
-
-
Save adityatyagi/da055a91163be48bd367478f65ee07ee 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
// in App.js (Parent component) | |
... | |
... | |
... | |
// this function is re-created on ever re-execution of this function | |
const onDemoClick = () => { | |
console.log('Demo clicked!'); | |
} | |
return ( | |
<div> | |
<h2>Virtual DOM demo by Aditya Tyagi</h2> | |
{/* because onDemoClick is re-created, the DemoOutput component is re-executed every-time, even though nothing changes in the function */} | |
<DemoOutput onClick={onDemoClick} /> | |
<button onClick={togglePara}>Toggle</button> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment