Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adityatyagi
Created June 7, 2022 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityatyagi/da055a91163be48bd367478f65ee07ee to your computer and use it in GitHub Desktop.
Save adityatyagi/da055a91163be48bd367478f65ee07ee to your computer and use it in GitHub Desktop.
// 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