reactjs - ReferenceError:找不到变量:React 上的 regeneratorRuntime
问题描述
我正在尝试使用 react 和 firebase 创建登录。我一直在关注一个教程,问题是这段代码:
const handleLogin = useCallback(
async event => {
event.preventDefault();
const { email, password } = event.target.elements;
try {
await firebaseConfig.auth().signInWithEmailAndPassword(email.value, password.value);
history.push("/citas")
} catch (error) {
alert(error);
}
},
[history]
);
给我这个错误:
ReferenceError:找不到变量:regeneratorRuntime
我没有找到任何解决方案,因为我不知道这意味着什么。有任何想法吗?
解决方案
使用 @babel/polyfill 已被正式弃用。由于您使用的是 react 应用程序(并且不依赖于遗留代码库),您可能更喜欢使用以下内容:
npm i --save core-js/stable regenerator-runtime
// ECMA Script Polyfills:
import "core-js/stable";
// Needed for the generator functions which are transpiled from your async await keywords
import "regenerator-runtime/runtime";
推荐阅读
- aws-lambda - 对 lambda 函数的调用者进行身份验证
- android - android - 如何从状态栏中删除黑暗
- https - Traefik 反向代理后的 Plone 的混合内容问题
- python - 按出现顺序获取 numpy 数组索引
- go - 如何使用 for 循环创建对象切片
- jvm - ActiveMQ 命令:无法分配内存
- svn - PhpStorm 显示 SVN 而不是真实的文件夹名称
- javascript - 有没有办法添加外部 DOM 对象(即) 到一个阶段或层?
- javascript - 如何将签名附加到文件?
- jquery - 如何修复忽略/未针对特定 ID 执行 jQuery 隐藏功能的脚本