You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Registering Service Worker causes NO INTERNET chrome page on default install #11987
Run a brand new create react app project and register a service worker. Build your app using yarn build and serve it using serve -s build. Open a new chrome tab in incognito mode. While the page will serve normally for the first 10 seconds, when the service worker activates, the page suddenly breaks with an appear offline message.
npx create-react-app@v5.0.0 my-app --template cra-template-pwa-typescript
cd my-app
yarn install
then apply this patch
diff --git a/src/index.tsx b/src/index.tsx
index e459b13..4a7b0ba 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -15,7 +15,7 @@ ReactDOM.render(
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
-serviceWorkerRegistration.unregister();
+serviceWorkerRegistration.register();
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
And finally build and serve
yarn build
serve -s build
Actual behavior
Try to open an incognito page on Google Chrome (v97 or above). The page will load for a few seconds. If you refresh the page and show the inspector and go to the Application tab, it displays the dinosaur.
Activity
baimMN commentedon Aug 21, 2022
same here