-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiples Components best practices: sharing bridge? #1073
Comments
Yes, you can create the bridge using
Then store that in a property somewhere (e.g. in your AppDelegate), and whenever you need to create a root view, say:
That way the JS code bundle is shared, and each root view runs its own component. |
Hi. thanks for the response. |
@finalquest - |
hey guys, if i take it correctly, if i want to share the same bridge, then i need to bundle all the js files/functions to a big |
@dolmens - what's your use case? |
@brentvatne say i choose to place the js bundle on server side, and i have many react views, named v1, v2, ..., etc., corresponding to js module m1, m2, ..., etc., and i want to download these modules on demand, in other words, i don't download them only until i show the corresonding views. |
@dolmens - Ah, interesting. As far as I know, this is not supported at the moment, but @tadeuzagallo or @ide would know better than I |
Yeah, @brentvatne is right, it's not possible yet... The bridge holds where to require the javascript bundle, the RootView just knows which module to require, but it has to be previously loaded by the bridge. |
@brentvatne can you give some more details about how to put multiple JS files into a single bundle, using react-native bundle? |
Hi again.
The context first:
Im using RN as the V in MVC. I've created a JS with a RN component, created a UIView in the obj-c side, and use a RCTRootView (initWithBridge) as a subview.
Everything works fine.
Now the question.
Suppose that I have a two RN components, in two JS files (DetailView.js, SomeOtherView.js).
Is there a way to make a single JS file with the 2 components, so I can use only one bridge and share it. I dont really understand how can I achieve this, and use initWithBridge: moduleName:
Sorry if is a super noob question.
Thanks and regards
The text was updated successfully, but these errors were encountered: