Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kellyrmilligan
Created June 8, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellyrmilligan/a09c8cca4ffe312512feba6e27253d09 to your computer and use it in GitHub Desktop.
Save kellyrmilligan/a09c8cca4ffe312512feba6e27253d09 to your computer and use it in GitHub Desktop.
sending a notification when service worker is updated in top level component
componentWillReceiveProps (nextProps) {
// see if new content was found by the service worker
if (nextProps.serviceWorker.serviceWorkerUpdated) {
this.setState({
notifications: this.state.notifications.concat({
'The app has been updated! Hooray! Refresh your browser to enjoy the latest and greatest',
'some unique key',
action: 'Dismiss',
dismissAfter: 4000,
onClick: this.removeNotification
})
})
}
}
///down in render land
render () {
return (
<section className='App'>
<NotificationStack
notifications={this.state.notifications}
onDismiss={this.removeNotification}
/>
</section>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment