Last active
December 8, 2015 06:16
-
-
Save paulruescher/97ab1b6143c8e05605a8 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
const Container = React.createClass({ | |
componentDidMount() { | |
const success = (notifications) => { | |
this.setState({ | |
notifications: notifications, | |
}); | |
}; | |
$.ajax({ | |
url: '/notifications', | |
dataType: 'json', | |
success: success, | |
}); | |
}, | |
onMarkAsRead(id) { | |
// some mark as read logic | |
}, | |
render() { | |
return ( | |
<Presentation | |
notifications={this.state.notifications} | |
onMarkAsRead={this.onMarkAsRead} | |
/> | |
); | |
}, | |
}); | |
const Presentation = React.createClass({ | |
renderNotification({notification}) { | |
const { id, date, message } = notification; | |
return ( | |
<div> | |
<span>{message} — {date}</span> | |
<button onClick={this.props.onMarkAsRead.bind(null, id)}>Mark as Read</button> | |
</div> | |
); | |
}, | |
render() { | |
return <div>{this.props.notifications.map(renderNotification)}</div>; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment