Skip to content
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

Create advanced example of native navigation loading RN views #4

Open
dsibiski opened this issue Sep 8, 2015 · 0 comments
Open

Create advanced example of native navigation loading RN views #4

dsibiski opened this issue Sep 8, 2015 · 0 comments

Comments

@dsibiski
Copy link
Owner

dsibiski commented Sep 8, 2015

One way may be to hook into NavigatorIOS's backing viewController like this:

 - (RCTRootView *)sceneReactNavigator {
    UIView *parent = (UIView *)self.reactSuperview;
    while(parent != nil) {
        if([parent.nextResponder isKindOfClass:[UINavigationController class]]) {
            return (RCTRootView *)parent.nextResponder;
        }
        parent = (UIView *)parent.reactSuperview;
    }
    return nil;
}

Code example came from this discussion: facebook/react-native#2442. As is discussed there, however, this is probably brittle and not recommended.

If we don't take this approach, we probably need to be able to pass components to the native module controlling the navigation controller and then push those component onto the navigation stack. This will enable the navigation to be controlled from RN or Obj-C.

The benefit of this would be that we could push native Obj-C and RN views onto the same navigation stack without having to have it all implemented on one side.

The more I think about it though, I'm not sure this is the best thing to encourage. It might be better to simply encourage keeping navigation native in Obj-C at first, and just use RN views where they are needed. Then, when one full branch of navigation has RN implemented for each screen, move the navigation into RN. If there is a view that is very hard to port to RN, it could easily be wrapped as a native view module and called from RN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant