【发布时间】:2021-08-16 15:03:06
【问题描述】:
- RN 版本:0.50
- 在 Android 上测试,尚未在 iOS 上测试
我正在尝试使用ErrorUtils.setGlobalHandler,如此 github 问题中所述:https://github.com/facebook/react-native/issues/1194
但是,问题中不清楚的是如何导入 ErrorUtils。它不在反应文档中:https://facebook.github.io/react-native/docs/0.50/getting-started.html
以前,在 RN 0.41 中,我可以使用 import ErrorUtils from "ErrorUtils"; 导入 ErrorUtils 但是,在 0.50 中,当我尝试像这样导入 ErrorUtils 时,我会收到一个红色的反应弹出窗口,并显示以下消息:
com.facebook.react.common.JavascriptException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8081/index.bundle?platform=android&dev=true&minify=false' failed to load.
我也尝试过import { ErrorUtils } from 'react-native';,但那里似乎不存在。错误是:
Cannot read property 'setGlobalHandler' of undefined
如何在 RN 0.50 中正确导入 ErrorUtils?
【问题讨论】:
标签: react-native