【问题标题】:React native build on real device crashes (emul working)在真实设备崩溃时反应原生构建(emul 工作)
【发布时间】:2018-08-29 03:45:01
【问题描述】:

有人可以就我在这里做错了什么提出建议吗?

当通过XCode (9.2) 模拟器启动应用程序时,应用程序工作正常,在真实设备上构建它时 (iOS 11.2.6) 会进一步引发错误: 尝试了此处描述的步骤:https://github.com/facebook/react-native/issues/4831

2018-03-20 12:05:22.400152+0500 qatar[1134:528934] *** Terminating app due to uncaught 
exception 'RCTFatalException: Unhandled JS Exception: 
TypeError: babelHelpers.objectDestructuringEmpty is not a function. 
(In 'babelHelpers.objectDestructuringEmpty(e)', 
'babelHelpers.objectDestructuringEmpty' is undefined)

This error is located at:
in Unknown
in t
in Connect(t)
in RCTView
in t
in RCTView
in RCTView
in RCTView
in t
in t
in t
in Connect(t)
in t
in RCTView
in n
in t
in n
in RCTView
in RCTView
in t
in RCTView
in e
in r
in Unknown
in n
in n
in t
in t
in withCachedChildNavigation(t)
in Unknown
in n
in RCTView
in n
in RCTView
in t
in t
in Unknown
in n
in n
in RCTView
in t
in Styled(t)
in n
in Unknown
in t
in Translate(Component)
in t
in RCTView
in RCTView
in t', reason: 'Unhandled JS Exception: TypeError: babelHelpers.objectDestructuringEmpty is..., stack:
default@738:198
<unknown>@46:29910
q@46:47194
ee@46:47795
ne@46:48869
le@46:51343
enqueueSetState@46:25514
setState@53:915
dispatch@857:822
<unknown>@855:668
b@23:628
callTimers@23:2773
value@18:3078
<unknown>@18:812
value@18:2507
value@18:784

Android 给出了类似的错误:

【问题讨论】:

  • 这个问题你解决了吗?

标签: react-native react-native-android react-native-ios


【解决方案1】:

您是否创建了 bundle.js 文件? 试试这个:

react-native bundle --entry-file='index.js' --bundle-output='./ios/AppName/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'

你能提供更多关于你的 .babelrc 文件的信息吗?

【讨论】:

    【解决方案2】:

    我在安装 babel helper 插件时得到了这个修复。

    Package.json:
    "devDependencies": {
    "babel-cli": "6.26.0",
    "babel-plugin-external-helpers": "^6.22.0",
    ....
    }
    
    babelrc:
    {
    "presets": ["react-native", "flow"],
    "plugins": [
    "external-helpers",
    ...
    ]
    }
    

    安装此插件的参考: https://www.npmjs.com/package/babel-plugin-external-helpers

    【讨论】:

    • 我正面临这个问题,我对其他线程中的每个人都只是说“从你的代码中删除空的解构”感到有点不安。这是一件完全有效的事情。作为一个存根方法,它很有用。我想在此处添加插件会有所帮助,因为除了电话之外,我现在还遇到了模拟器上的崩溃。与之前的电话相反(这是一个令人讨厌的惊喜)。我会接受的。但我希望它消失,所以我可以使用 const { } = this.props;
    • ^ 似乎在迁移到 RN 0.57 和其他一些兼容的 deps 后得到修复。我现在可以正确使用该语言了。开发部门:"metro-react-native-babel-preset": "^0.48.3", "react-test-renderer": "^16.6.0-alpha.8af6728", 部门:"react": "^16.6.0-alpha.8af6728", "react-native": "0.57.4", .babelrc:"plugins": [ [ "module:metro-react-native-babel-preset" ] ]
    猜你喜欢
    • 2021-07-31
    • 2023-04-09
    • 1970-01-01
    • 2022-11-11
    • 2020-04-23
    • 1970-01-01
    • 2019-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多