dsibiski / react-native-hybrid-app-examples

A collection of examples for using React Native in an existing iOS application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create advanced example using an Obj-C category

dsibiski opened this issue · comments

Try making the "Native Modal With RN Navigation" example using a category like the following example:

https://github.com/alinz/react-native-webview-bridge/blob/master/WebViewBridge/RCTWebViewManager%2BWebViewManager.m

Also, at times composition could help extend a RN component. Not sure if this applies to Native Modal with RN Nav example.

Both these techniques(category, composition) are used here:

  1. [composition] github.com/chirag04/react-native-tooltip
  2. [category] https://github.com/chirag04/tooltip

@chirag04 Thanks! I've looked at your tooltip project many times before as it has some very interesting solutions.

Essentially, the example referred to here is when you have an Obj-C view that loads a RCTBridge or RCTRootView. Sometimes you may want to expose methods from that base view to RN as a bridge module. However, when you create the bridge, JS has access to a different instance than Obj-C, since the bridge instantiates all bridge modules at load. This prevents you from being able to call methods on the view actually visible from JS. (I hope that isn't too confusing! hah)

I've discovered a couple different ways to do this, and an Obj-C category was suggested as one of them.