Topic: the line serviceWorker.unregister() doesn't exist

desarrolloglobal free asked 4 years ago


**I bought React Super Bundle, then I am taking the react course, in this class: https://mdbootstrap.com/education/react/pwa-4-https-and-service-workers/ say: to open src/index.js file and change one line. Change serviceWorker.unregister() but I can´t find this line in index.js. I try to download this lesson in the repository https://github.com/mdbootstrap/React-Tutorial-PWA/archive/master.zip but this not found.**

**I wrote the line, but show me the error : Line 9: 'serviceWorker' is not defined no-undef.**

****


Jakub Chmura staff answered 4 years ago


Hi @desarrolloglobal,

You need to import servceWorker file to your index.js and then you be able to change serviceWorker to register.

I'll show you an example, how should your index.js look like.

import React from 'react';
import ReactDOM from 'react-dom';
import '@fortawesome/fontawesome-free/css/all.min.css';
import 'bootstrap-css-only/css/bootstrap.min.css';
import 'mdbreact/dist/css/mdb.css';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

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

// 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://bit.ly/CRA-PWA

serviceWorker.unregister();

Please tell me if you solve this problem.

Best, Kuba



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.25.3
  • Device: Nokia Android 10
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes