From daaa9b2c79ffa9fc4a81a28ca2fd15872f3aa50a Mon Sep 17 00:00:00 2001 From: Charlie Gleason Date: Tue, 26 Sep 2017 16:58:37 +0100 Subject: [PATCH] Clarify registering and unregistering service workers in README.md Following on from https://github.com/facebookincubator/create-react-app/issues/2715 this PR updates the README.md with updated instructions for opting out of PWA features. --- packages/react-scripts/template/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 98e26c98e81..c5311eaa86d 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1581,16 +1581,17 @@ that your web app is reliably fast, even on a slow or unreliable network. ### Opting Out of Caching If you would prefer not to enable service workers prior to your initial -production deployment, then remove the call to `serviceWorkerRegistration.register()` +production deployment, then remove the call to `registerServiceWorker();` from [`src/index.js`](src/index.js). If you had previously enabled service workers in your production deployment and have decided that you would like to disable them for all your existing users, -you can swap out the call to `serviceWorkerRegistration.register()` in -[`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`. -After the user visits a page that has `serviceWorkerRegistration.unregister()`, -the service worker will be uninstalled. Note that depending on how `/service-worker.js` is served, -it may take up to 24 hours for the cache to be invalidated. +you can swap out the call to `registerServiceWorker();` in [`src/index.js`](src/index.js) +with a call to `unregister();` - you will need to ensure you have imported +`unregister` by replacing `import registerServiceWorker from './registerServiceWorker';` with +`import { unregister } from './registerServiceWorker';`. After the user visits a page that has +`unregister();`, the service worker will be uninstalled. Note that depending on how +`/service-worker.js` is served, it may take up to 24 hours for the cache to be invalidated. ### Offline-First Considerations