Last active
April 1, 2020 10:29
-
-
Save cant89/f284e07dac2ac48027ce378ae296fd83 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, { Fragment } from "react"; | |
class WelcomeMessage extends React.Component { | |
render() { | |
console.log("render WelcomeMessage"); | |
return <label>Hello {this.props.user}</label>; | |
} | |
} | |
class Page extends React.PureComponent { | |
state = {}; | |
render() { | |
console.log("render Page"); | |
return ( | |
<Fragment> | |
<WelcomeMessage user={this.state.user} /> | |
<button onClick={() => this.setState({ user: "Jack" })}> | |
Set User | |
</button> | |
</Fragment> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment