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

275
Views
¿Cómo entrar y salir del módulo nativo en React Native?

Mi pregunta tiene que ver con los módulos nativos en React y cómo cambiar entre vistas Js y módulos nativos escritos en Swift. El código que tengo es bastante repetitivo de varios ejemplos.

La función goToNativeView a continuación intercambia el rootViewController para ingresar el código Swift (a través del archivo principal del guión gráfico). ¿Cómo instrumentaría una llamada de función de Swift para volver a mi aplicación Javascript?

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; }

En mi React Component, tengo una función simple que habilita el módulo nativo. Supongo que necesito una devolución de llamada o un oyente para la llamada de salida

Aplicación.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!