Destructuring from props is not working inside an async function while it's working fine if I use it using this.props.

这是为一个已经在生产中的react-native 应用程序编写的,该应用程序突然开始在两天前返回此错误.

但到目前为止还没有成功.

如果我用this.props.getLoginData代替,效果很好

如果我使用以下函数,它是错误的:

yo = async () => { // with async
  const { getLoginData } = this.props; // error
};

虽然以下功能可以正常工作:

yo = () => { // without async
  const { getLoginData } = this.props;
  console.log(getLoginData); // works fine
};

这也很好:

yo = async () => { // with async
  console.log(this.props.getLoginData); // works fine
};

我预计这两种情况都会很好.

Please clone and run 100 to reproduce this bug.

请在自述文件中找到运行项目的步骤和环境信息.医学博士.

提示:您将在控制台中找到错误(按⌘⌥(一)

推荐答案

在我的 case 中,似乎巴别塔的依赖是问题的原因.

当我查看我的package-lock.json,搜索plugin-transform-regenerator时,我会看到版本7.4.5.通过将版本添加到我的package.json中,将其锁定为7.4.4,使我可以毫无问题地进行构建.

如果我没有忽略我的package-lock.json分,这个问题会更容易找到.

总之,

npm i -E @babel/plugin-transform-regenerator@7.4.4

React-native相关问答推荐

错误:HostBody::get for prop NativeUnimoduleProxy中出现异常- Android虚拟设备(AVD)使用Expo测试React Native App时崩溃

对iOS通知上未显示的本机映像做出react

如何在Reaction本地日历中 Select 年份?

如何在底部标签导航中添加顶部标签

如何在react native 中从 axios 重定向并将数据传递给路由

为什么当键盘出现在react native 时我的按钮会上升?按钮视图位置是绝对的?

Error: Invariant Violation: Touchable child must either be native or forward setNativeProps to a native component stack

如何在react-native 中设置视图的自动高度

使用 React Native 下载数据文件以供离线使用

Eslint 错误,configuration for rule "import/no-cycle" is invalid

Android Studio 为构建设置 node 目录(Cause: error=2, No such file or directory)

如何实时从 react-native-camera 获取帧

错误:安装 react-native-elements 后无法识别字体系列 Material Design 图标?

在 React Native (iOS) 中支持动态类型

是否可以在 react-native 的构造函数中调用异步函数?

Android Log

React-native iOS 不显示图像(pod 问题)

React Native:文本 node 的 Auto宽度

将 colored颜色 变量导入我的样式

如何更改后退按钮标签,react-navigation