Created
January 31, 2018 18:48
-
-
Save chris-burgin/38e93fe5a56362b5d132d9a613f4af07 to your computer and use it in GitHub Desktop.
A breakdown of the MessageComponent that shows an example using shouldComponentUpdate()
This file contains hidden or 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
class Message extends Component { | |
shouldComponentUpdate(nextProps) { | |
if (this.props.message === nextProps.message) { | |
return false | |
} | |
return true | |
} | |
render() { | |
return <li style={{ margin: "10px" }}> {this.props.message} </li> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment