Skip to content

Commit

Permalink
Disable service worker by default (#3817)
Browse files Browse the repository at this point in the history
* WIP disable service worker by default (#2554)

* Updated service worker registration

* Readd default export in registerServiceWorker.js

* Updated comments about using Service Worker

* Call it serviceWorker

* Nits
  • Loading branch information
iansu authored and gaearon committed Jan 19, 2018
1 parent 864874b commit 0e51eef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/react-scripts/template/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

// 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: http://bit.ly/2vJdu84
serviceWorker.unregister();
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const isLocalhost = Boolean(
)
);

export default function register() {
export function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
Expand Down

0 comments on commit 0e51eef

Please sign in to comment.