React = require 'react' NotificationStore = require './notifications-store' module.exports = Notifications = React.createClass getInitialState: -> notifications: NotificationStore.notifications() componentDidMount: -> @unsubscribeStore = NotificationStore.listen @_onStoreChange componentWillUnmount: -> @unsubscribeStore() if @unsubscribeStore render: ->
{ for notification in @state.notifications
{notification.message}
}
_onStoreChange: -> @setState notifications: NotificationStore.notifications()