简体   繁体   中英

Create React App shows serviceWorker.js and not the registerServiceWorker that a lot of tutorials show

When I figured I would use Visual Studio Code to get a new React JS application started with learning it etc.. I ran across Microsoft site https://code.visualstudio.com/docs/nodejs/reactjs-tutorial In which this shows to

import registerServiceWorker from './registerServiceWorker';

Meanwhile, there doesn't exist, when I create a new react app it has an index.js file with

import * as serviceWorker from './serviceWorker';
// 
serviceWorker.unregister();
  1. I don't like learning something that is outdated /deprecated so quickly … Is there a much better up to date place to figure out what I am supposed to do to be learning and productively engaged with React JS?
  2. Seems that registerServiceWorker(); was common but is this completely outdated? What does registerServiceWorker do in React JS?
  3. I want to really just get into calling Restful endpoints of web api, what is a good place to do find best practices to do this?

The serviceWorker support is a part of Create React App (the CLI tool, not React itself). Its official docs are a great place for up-to-date information:

switching serviceWorker.unregister() to serviceWorker.register() will opt you in to using the service worker.

As for learning React, while there are a number of great tutorials out there, you can rely on the official tutorial to always reflect the latest version.

React, being just a view library, doesn't prescribe a standard way to make HTTP requests. You can use any popular request library or just plain old Fetch API , and React will play nice with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM