[英]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 当我想到我会使用Visual Studio Code来开始学习它的新的React JS应用程序等。我遇到了Microsoft网站https://code.visualstudio.com/docs/nodejs/reactjs-tutorial ,其中显示了
import registerServiceWorker from './registerServiceWorker';
Meanwhile, there doesn't exist, when I create a new react app it has an index.js file with 同时,不存在,当我创建一个新的react应用时,它具有一个index.js文件,
import * as serviceWorker from './serviceWorker';
//
serviceWorker.unregister();
registerServiceWorker();
似乎registerServiceWorker();
was common but is this completely outdated? 很常见,但这完全过时了吗? What does registerServiceWorker do in React JS? registerServiceWorker在React JS中做什么? The serviceWorker support is a part of Create React App (the CLI tool, not React itself). serviceWorker支持是Create React App(CLI工具,不是React本身)的一部分。 Its official docs are a great place for up-to-date information: 它的官方文档是获取最新信息的好地方:
switching
serviceWorker.unregister()
toserviceWorker.register()
will opt you in to using the service worker. 将serviceWorker.unregister()
切换为serviceWorker.register()
将使您选择使用服务工作者。
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,虽然有很多很棒的教程,但是您可以依靠官方教程来始终反映最新版本。
React, being just a view library, doesn't prescribe a standard way to make HTTP requests. 作为一个视图库,React并未规定发出HTTP请求的标准方法。 You can use any popular request library or just plain old Fetch API , and React will play nice with it. 您可以使用任何流行的请求库,也可以使用普通的旧Fetch API ,React可以很好地使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.