react-nativereact-native-navigationwix-react-native-navigation

Passing properties from native to React Native when using Wix React Native Navigation (RNN)


Passing properties from native to React Native is described here. Here's a summary:

NSArray *imageList = @[@"http://foo.com/bar1.png",
                       @"http://foo.com/bar2.png"];

NSDictionary *props = @{@"images" : imageList};

RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                 moduleName:@"ImageBrowserApp"
                                          initialProperties:props];

However, when using Wix React Native Navigation, there is no rootView. According to the docs, this is what a minimal RNN setup looks like on iOS:

 #import "AppDelegate.h"

 #import <React/RCTBundleURLProvider.h>
 #import <React/RCTRootView.h>
 #import <ReactNativeNavigation/ReactNativeNavigation.h>

 @implementation AppDelegate

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
     NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
     [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

     return YES;
 }

 @end

How do we go about passing props from native?


Solution

  • You'll need to create a native module for that. The module exposes public methods which return results by resolving a promise.