Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
How to move in AND OUT of Native Module in React Native?

My question has to do with native modules in React and how to switch between Js views and a Swift written native modules. The code I have is pretty boilerplate from various examples.

The goToNativeView function below swaps out the rootViewController to enter the Swift code (through the Main storyboard file). How would I instrument a function call from Swift to return back to my Javascript application?

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"RNImageCollectorV2"
                                            initialProperties:nil];

  if (@available(iOS 13.0, *)) {
      rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
      rootView.backgroundColor = [UIColor whiteColor];
  }

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

// this method will be called from the RCTBridge
- (void) goToNativeView {
    NSLog(@"RN binding - Native View - CameraViewController.swift - Load From main storyboard");
    UIViewController *vc = [UIStoryboard storyboardWithName:@"Main" bundle:nil].instantiateInitialViewController;
    self.window.rootViewController = vc;
}

In my React Component, I have a simple function that enables the native module. I'm assuming I need a callback or listener for the exit call

App.tsx

class App extends Component {

  constructor(props) {
    super(props)
  }

  _changeView = () => {
    // this.done = true;
    // this.render();
    NativeModules.ChangeViewBridge.changeToNativeView();
  };

  render() {
    return (
       <TouchableHighlight onPress={() => this._changeView()}>
                <Text color="#336699">Press to Change to Native View</Text>
              </TouchableHighlight>
  )}
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!