Created
October 3, 2019 04:43
-
-
Save 9oelM/da3f3c6a7e843c27bbcc7c744e007137 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
import React, { useState } from 'react'; | |
const Child1 = () => { | |
console.log('Child1 rendered') | |
return <div style = {{border: '1px solid red', padding: '30px'}}> | |
Child1 | |
</div> | |
} | |
const Child2 = () => { | |
console.log('Child2 rendered') | |
return <div style = {{border: '1px solid red', padding: '30px'}}> | |
Child2 | |
</div> | |
} | |
const Parent = () => { | |
console.log('Parent rendered') | |
let [count, setCount] = useState(0) | |
const handleMouseEnter = () => setCount(prevCount => prevCount + 1) | |
return <div onMouseEnter={handleMouseEnter} style = {{border: '1px solid black', padding: '50px'}}> | |
Parent. Count: {count} | |
<Child1/> | |
<Child2/> | |
</div> | |
} | |
export default Parent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment