Skip to content

Commit

Permalink
Disable service worker by default (facebook#3817)
Browse files Browse the repository at this point in the history
* WIP disable service worker by default (facebook#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 akstuhl committed Mar 15, 2018
1 parent 1133ea0 commit 31b5ff9
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 31b5ff9

Please sign in to comment.