Skip to content

Instantly share code, notes, and snippets.

@paulruescher
Created November 11, 2015 23:34
Show Gist options
  • Save paulruescher/06f2033416286bb8bccc to your computer and use it in GitHub Desktop.
Save paulruescher/06f2033416286bb8bccc to your computer and use it in GitHub Desktop.
const notifications = [
{
date: "Nov 10, 2015 8:00:00",
message: "Tagged in a photo",
},
{
date: "Nov 10, 2015 9:00:00",
message: "Mentioned in a post",
},
];
// "Smart" notification component
const NotificationsContainer = React.createClass({
componentWillMount() {
this.setState({
notifications
});
},
render() {
const Component = this.props.component;
return (
<Component
notifications={this.state.notifications}
/>
);
},
});
// "Dumb" notification component
const Notifications = React.createClass({
render() {
return (
<div>
{this.props.notifications.map(notification => {
return (
<div>
<span>{notification.message}</span>
<span>{notification.date}</span>
</div>
);
})}
</div>
);
},
});
// useage
const App = React.createClass({
render() {
return (
<div>
<NotificationsContainer
component={Notifications}
/>
</div>
);
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment