tristanbbq
tristanbbq

Reputation: 605

React Native app stuck on blank screen when running on device with remote debugging

I run my react native application on my device (iPhone 6) and it loads fine. But when I enable remote debugging, it seems to connect fine to debugger but gets stuck on a blank screen.

As soon as I turn off remote debugging, everything loads fine.

I am on react-native 0.40.0.

Please help!

Upvotes: 10

Views: 3626

Answers (3)

Anmol Suneja
Anmol Suneja

Reputation: 107

I was facing this same issue when launching a react native module from iOS native module.

Replacing below mentioned code using BUNDLE URL

    if let bundleUrl = (UIApplication.shared.delegate as? AppDelegate)?.bridge?.bundleURL {
    let mockData:NSDictionary = ["names":
        [
            ["name":"Name 1",],
            ["name":"Name 2"]
        ]
    ]
    
    let rootView = RCTRootView(bundleURL: bundleUrl, moduleName: "modulename", initialProperties: mockData as [NSObject : AnyObject], launchOptions: nil)
    
    let vc = UIViewController()
    vc.view = rootView
    self.present(vc, animated: true, completion: nil)

with this updated code using BRIDGE

    if let bridge = (UIApplication.shared.delegate as? AppDelegate)?.bridge {
    let mockData:NSDictionary = ["names":
        [
            ["name":"Name 1",],
            ["name":"Name 2"]
        ]
    ]
    
    let rootView = RCTRootView(bridge: bridge, moduleName: "modulename", initialProperties: mockData as [NSObject : AnyObject])
    
    let vc = UIViewController()
    vc.view = rootView
    self.present(vc, animated: true, completion: nil)
}

resolve the issues!!

Upvotes: 0

Kashan Haider
Kashan Haider

Reputation: 1204

There can be many reasons, in my case it was the cache that was creating problem. Suggested Solutions:-

  1. Clean gradlew - To clean gradle go to android folder and open cmd in it, run 'gradlew clean' in the cmd
  2. after cleaning gradle, re-build your app run command (run-android etc)
  3. if the problem exist after rebuilding follow step 4 & 5
  4. Go to App's setting and clear App's data
  5. now clear react-native terminal's cache ( react-native start --reset-cache )

These steps will fix the problem!

Upvotes: 1

Roman
Roman

Reputation: 21873

I overcome this effect by doing the following:

  1. go to the terminal and press "a" to reopen Android device or emulator
  2. close application on mobile device and open it once again
  3. if necessary, restart R to restart packager and clear cache in the terminal

Upvotes: 0

Related Questions