Topic: the line serviceWorker.unregister() doesn't exist
desarrolloglobal free asked 3 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.**
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.
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: 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