简体   繁体   English

Create React App显示的是serviceWorker.js,而不是很多教程显示的registerServiceWorker

[英]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();
  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? 我不喜欢这么快地学习过时/过时的东西……有没有更好的最新地方来弄清楚我应该做些什么来学习和有效地使用React JS?
  2. Seems that registerServiceWorker(); 似乎registerServiceWorker(); was common but is this completely outdated? 很常见,但这完全过时了吗? What does registerServiceWorker do in React JS? registerServiceWorker在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? 我真的想真正地调用Web API的Restful端点,在哪里找到实现此目标的最佳实践的好地方?

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() to serviceWorker.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.

相关问题 我得到 reactjs serviceWorker.js 而不是 registerServiceWorker.js - I get reactjs serviceWorker.js instead of registerServiceWorker.js React - 在 app src 文件夹中找不到 serviceWorker.js 文件 - React - Can't find serviceWorker.js file in app src folder Create-react-app registerServiceWorker在getRegistration()承诺中提供未定义 - Create-react-app registerServiceWorker giving undefined at getRegistration() promise serviceworker.js不断指向javascript文件中的错误路径 - serviceworker.js keeps pointing to incorrect path from javascript file ServiceWorker 更新循环 - 创建反应应用程序 - ServiceWorker Update loop - Create react app registerServiceWorker在React JS中做了什么? - What does registerServiceWorker do in React JS? 在React中是否需要registerServiceWorker.js? - Within React is registerServiceWorker.js Required? 为什么我在文件夹 src 中看不到 serviceWorker.js? - Why I don't see serviceWorker.js in my folder src? 即使在 serviceworker.js 的 addEventListener 中注册,notificationclick 也不会在 chrome 中触发 - notificationclick does not fire in chrome even though registered in addEventListener in serviceworker.js [React.js] 尝试导入错误:'./registerServiceWorker' 不包含默认导出(导入为 'registerServiceWorker') - [React.js]Attempted import error: './registerServiceWorker' does not contain a default export (imported as 'registerServiceWorker')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM