小编Shr*_*lox的帖子

React 本机错误窗口导致 iOS 崩溃

我按照官方网站上的说明将 React Native 集成到我现有的 iOS 应用程序中。它大部分时间都可以工作,但是当出现 Js 错误并且它应该显示 React Native 红色错误窗口时,应用程序反而崩溃了。我使用 RN 0.59

有什么我想念的吗?

这是我在应用程序中添加 React Native 的代码:

显示 RCTRootView 的视图控制器:

class OnboardingViewController : UIViewController {
    var onboardingView: RCTRootView!

    override func viewDidLoad() {
        super.viewDidLoad()

        self.onboardingView = ReactNativeBridge.instance.viewForModule("Onboarding", initialProperties: ["locale" : "language_http_key".localize()])
        self.onboardingView.backgroundColor = UIColor.bbgBrandGreenColor()
        self.view.addSubview(self.onboardingView)
        if ((self.onboardingView) != nil) {
            self.onboardingView.frame = self.view.bounds
        }
    }

    override var preferredStatusBarStyle : UIStatusBarStyle {
        return UIStatusBarStyle.lightContent
    }
}
Run Code Online (Sandbox Code Playgroud)

ReactNativeBridge 实现:

class ReactNativeBridge: NSObject {
    static let instance = ReactNativeBridge()
    var bridge: RCTBridge?

    func …
Run Code Online (Sandbox Code Playgroud)

ios react-native

5
推荐指数
1
解决办法
418
查看次数

标签 统计

ios ×1

react-native ×1