Create React App shows serviceWorker.js and not th

2019-08-17 17:56发布

问题:

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?

回答1:

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.