|
@ -11,12 +11,13 @@ class Button extends React.Component { |
|
|
class Message extends React.Component { |
|
|
class Message extends React.Component { |
|
|
render() { |
|
|
render() { |
|
|
// highlight-range{1-3}
|
|
|
// highlight-range{1-3}
|
|
|
// The Message component must take `color` as as prop to pass it
|
|
|
// The Message component must take `color` as as prop to pass it
|
|
|
// to the Button. Using context, the Button could connect to the
|
|
|
// to the Button. Using context, the Button could connect to the
|
|
|
// color context on its own.
|
|
|
// color context on its own.
|
|
|
return ( |
|
|
return ( |
|
|
<div> |
|
|
<div> |
|
|
{this.props.text} <Button color={this.props.color}>Delete</Button> |
|
|
<p>{this.props.text}</p> |
|
|
|
|
|
<Button color={this.props.color}>Delete</Button> |
|
|
</div> |
|
|
</div> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -24,10 +25,10 @@ class Message extends React.Component { |
|
|
|
|
|
|
|
|
class MessageList extends React.Component { |
|
|
class MessageList extends React.Component { |
|
|
render() { |
|
|
render() { |
|
|
const color = "purple"; |
|
|
const color = 'purple'; |
|
|
const children = this.props.messages.map((message) => |
|
|
const children = this.props.messages.map(message => ( |
|
|
<Message text={message.text} color={color} /> |
|
|
<Message text={message.text} color={color} /> |
|
|
); |
|
|
)); |
|
|
return <div>{children}</div>; |
|
|
return <div>{children}</div>; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|