Skip to content

Commit

Permalink
avoid TypeError on when registering service workers without config (f…
Browse files Browse the repository at this point in the history
…acebook#5301)

* avoid TypeError on when registering service workers without config

Fixes facebook#5299

* same before config.onUpdate
  • Loading branch information
Peter Bengtsson authored and Timer committed Oct 5, 2018
1 parent f6c61b8 commit 6d95977
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions template/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function registerValidSW(swUrl, config) {
console.log('New content is available; please refresh.');

// Execute callback
if (config.onUpdate) {
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
Expand All @@ -78,7 +78,7 @@ function registerValidSW(swUrl, config) {
console.log('Content is cached for offline use.');

// Execute callback
if (config.onSuccess) {
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
Expand Down

0 comments on commit 6d95977

Please sign in to comment.