react native - Multiple RCTRootView in a single App -
i creating react native app require use of objective c build custom uiview. issue uiview need display react content. e.g. react text input , button. thinking adding rctrootview (which having these react components) custom uiview , solve issue. using 1 rctrootview. how create 1 , use in code.
edit: did understand can add different bundle server how-to-rename-react-native-entry-file-index-ios-js how use when running locally.
jscodelocation = [[nsbundle mainbundle] urlforresource:@"main" withextension:@"jsbundle"];
create rctrootview, other uiview.
rctrootview *somerootview = [[rctrootview alloc] initwithbundleurl:somejscodelocation modulename:@"somerootcomponent" launchoptions:nil]; rctrootview *anotherrootview = [[rctrootview alloc] initwithbundleurl:anotherjscodelocation modulename:@"anotherrootcomponent" launchoptions:nil]; you can specify same bundle (jscodelocation) rctrootviews, or different bundles each rctrootview. in either case best practice have different component names (modulename):
appregistry.registercomponent('somerootcomponent', () => somerootcomponent); appregistry.registercomponent('anotherrootcomponent', () => anotherrootcomponent); if maintain multiple bundles need compile each command:
curl 'http://localhost:8082/index1.ios.bundle?dev=false&minify=true' -o ios/main1.jsbundle curl 'http://localhost:8082/index2.ios.bundle?dev=false&minify=true' -o ios/main2.jsbundle main1.jsbundle , main2.jsbundle can added project , referenced normally.
Comments
Post a Comment