-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable service worker by default #3817
Changes from 1 commit
acdd348
5e15920
c6f3ca2
3402a41
184cec4
da2dce0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,16 @@ import React from 'react'; | |
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import App from './App'; | ||
import registerServiceWorker from './registerServiceWorker'; | ||
import registerServiceWorker, { | ||
unregister as unregisterServiceWorker, | ||
} from './registerServiceWorker'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
registerServiceWorker(); | ||
|
||
// By default we make sure that no service worker is registered. If you would | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People reading this probably don't know what service worker is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that's a challenge! 😀 I guess we can remove the first sentence and maybe link to that Google page from the docs about what a service worker is. Alternatively we could just link to the "Making a Progressive Web App" section of the CRA docs. I'll work on it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking something like // If you want your app to work offline and load faster, you can change “disable” below to “enable”.
// Note this comes with some deployment pitfalls.
// Learn more about service workers: <...> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it helps, https://developers.google.com/web/fundamentals/primers/service-workers/ attempts to be a one-stop landing page for a service worker overview, and https://developers.google.com/web/progressive-web-apps/ is a similar landing page for PWAs in general. |
||
// like to enable service worker uncomment the call to registerServiceWorker() | ||
// and comment out the call to unregisterServiceWorker(). | ||
// See http://bit.ly/2vJdu84 for more information. | ||
|
||
// registerServiceWorker(); | ||
unregisterServiceWorker(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing both of these results in a lint error because only one of them is ever used. We could override eslint for this line, we could only import one and update the comment below (ugh) or we could do something else entirely like only using
registerServiceWorker
and passing it a boolean to enable/disable.