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

Extend NavigatorIOS to support obj-c view controllers for hybrid apps #2886

Closed
wants to merge 1 commit into from

Conversation

paramaggarwal
Copy link
Contributor

Sharing something we are using to make the transition to React Native easier for us. We have a bunch of view controllers written in Objective-C that we would like to support while also using React Native on some of the other views in the navigation stack of NavigatorIOS.

This pull request shows how we are able to push the entire Objective-C view controller on NavigatorIOS as per the discretion of JS. From JS, we do something like this:

this.props.navigator.push({
  viewControllerStoryboard='SearchResults',
  viewControllerProperties={{
    title: 'Searching for Pizza around you',
    query: 'pizza'
  }}
});

On the Objective-C this instantiates SearchResults.storyboard, sets up the properties on it and pushes it onto NavigatorIOS. When a user taps on something, we notify JS back using the RCTDeviceEventEmitter with the event name onViewControllerEvent.

To use any existing pre-written view controller here, it simply needs to use the same methods and properties as the RCTWrapperViewController.

Would this be useful in the core?

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Sep 20, 2015
@javache
Copy link
Member

javache commented Oct 23, 2015

I think this would be great as a custom native module, but I don't think we want to support core native components managing other native view controllers.

@javache javache closed this Oct 23, 2015
@ide
Copy link
Contributor

ide commented Oct 23, 2015

Yeah, it's gnarly. I had done it before and come away with the conclusion that it's probably not something the RN team would want to maintain and can be really custom to each app. My sense was that if you weren't able to build this feature you wouldn't be able to keep it working and would just run into limitations and bugs.

@mhfc007
Copy link

mhfc007 commented Dec 1, 2015

I think this is great , because there are so many sdk provide the UI , you just need do some settings.
Such as RongCloud.cn , just a little setting ,then you get a chat app.

But In React Native , you can't use the sdk's view controllers !!!

I really need this feature, and I think the feature is very useful !!!

@paramaggarwal
Copy link
Contributor Author

@javache @ide Yes, you guys are right. We ourselves ended up abandoning this approach. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants