Mailspring/internal_packages/notifications/lib/notifications.cjsx
Evan Morikawa e3dfbe59be refactor(react): convert to class-based React components
Summary: Fix react upgrade errors

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1456
2015-04-30 13:08:29 -07:00

34 lines
869 B
CoffeeScript

React = require 'react'
NotificationStore = require './notifications-store'
class Notifications extends React.Component
@displayName: "Notifications"
constructor: (@props) ->
@state = notifications: NotificationStore.notifications()
componentDidMount: =>
@unsubscribeStore = NotificationStore.listen @_onStoreChange
componentWillUnmount: =>
@unsubscribeStore() if @unsubscribeStore
render: =>
<div className="notifications-momentary">
{@_notificationComponents()}
</div>
_notificationComponents: =>
@state.notifications.map (notification) ->
<div key={notification.id}
className={"notification-item notification-#{notification.type}"}>
{notification.message}
</div>
_onStoreChange: =>
@setState
notifications: NotificationStore.notifications()
module.exports = Notifications