Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

284
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda