Created
March 10, 2018 13:57
-
-
Save MicroBenz/e9e5cd09635efcf5e42fc67c9721e100 to your computer and use it in GitHub Desktop.
React Context
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 Button extends React.Component { | |
render() { | |
return ( | |
<button style={{background: this.props.color}}> | |
{this.props.children} | |
</button> | |
); | |
} | |
} | |
class Message extends React.Component { | |
render() { | |
return ( | |
<div> | |
{this.props.text} <Button color={this.props.color}>Delete</Button> | |
</div> | |
); | |
} | |
} | |
class MessageList extends React.Component { | |
render() { | |
const color = "purple"; | |
const children = this.props.messages.map((message) => | |
<Message text={message.text} color={color} /> | |
); | |
return <div>{children}</div>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment