mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-03-29 00:18:13 +08:00
avoid TypeError on when registering service workers without config (#5301)
* avoid TypeError on when registering service workers without config Fixes #5299 * same before config.onUpdate
This commit is contained in:
committed by
Joe Haddad
parent
ea15ebad8f
commit
e783bf8aed
@@ -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 {
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user