Created
June 8, 2017 14:49
-
-
Save kellyrmilligan/a09c8cca4ffe312512feba6e27253d09 to your computer and use it in GitHub Desktop.
sending a notification when service worker is updated in top level component
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
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