React Native - unable to make JS call: __fbBatchedBridge - undefined

I follow this tutorial https://www.raywenderlich.com/126063/react-native-tutorial

and decided to start from scratch after problems arose.

I started react-native init PropertyFinderand opened the project in Xcode. When I compile and run it, it opens in the Simulator, as expected:

enter image description here

but soon after that the screen disappears and shows this:

enter image description here

Error text:

Unable to execute JS call: __fbBatchedBridge is undefined

It worked less than 24 hours ago, so it’s not sure what is going on. Fwiw, I completely deleted the project and started again.

This answer ( Unable to make a JS call: __fbBatchedBridge - undefined ) suggests checking his code selection by wire. This does not mean that this is not a problem.

The full code in the App Delegate is as follows:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"

#import "RCTRootView.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  /**
   * Loading JavaScript code - uncomment the one you want.
   *
   * OPTION 1
   * Load from development server. Start the server from the repository root:
   *
   * $ npm start
   *
   * To run on device, change `localhost` to the IP address of your computer
   * (you can get this by typing `ifconfig` into the terminal and selecting the
   * `inet` value under `en0:`) and make sure your computer and iOS device are
   * on the same Wi-Fi network.
   */

  jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

  /**
   * OPTION 2
   * Load from pre-bundled file on disk. The static bundle is automatically
   * generated by the "Bundle React Native code and images" build step when
   * running the project on an actual device or running the project on the
   * simulator in the "Release" build configuration.
   */

//   jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"PropertyFinder"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end
+4
3

, , , . . AppDelegate.m ,

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

- , , . , React , .

.

+2

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/?platform=ios&dev=false"];

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=false"];

AppDelegate.m. - "index.ios.bundle", "index.ios", ".bundle" . .

0

Please check .

My problem is resolved by this solution.

0
source

All Articles