Last active
July 22, 2020 10:03
-
-
Save cant89/17c3d21f63eef0282f791631316ed5fb 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, Fragment } from "react"; | |
const WelcomeMessage = React.memo(({ name }) => { | |
console.log("render WelcomeMessage"); | |
return <label>Hello {name}</label>; | |
}); | |
const Page = () => { | |
const [user, setUser] = useState({}); | |
console.log("render Page"); | |
return ( | |
<Fragment> | |
<WelcomeMessage name={user.name} /> | |
<button onClick={() => setUser({ name: "Jack", age: 42 })}> | |
Set user | |
</button> | |
</Fragment> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment