Skip to content

use react-navigation! #9

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

Closed
chandu0101 opened this issue Apr 8, 2017 · 55 comments
Closed

use react-navigation! #9

chandu0101 opened this issue Apr 8, 2017 · 55 comments

Comments

@chandu0101
Copy link

https://microsoft.github.io/reactxp/docs/components/navigator.html

my guess is that when you guys built this there is no react-navigation, is it possible to adopt https://reactnavigation.org/ instead of creating one more navigation lib/API, we already have plenty now ;)

@chandu0101 chandu0101 changed the title use react-navigation use react-navigation! Apr 8, 2017
@kaiyes
Copy link

kaiyes commented Apr 8, 2017

Please . Sticking to React Navigation will be a god send.

@saint4eva
Copy link

saint4eva commented Apr 8, 2017

It may not be ideal as React Navigation only has support for Android and iOS - there is no support for UWP...

@dryganets
Copy link
Contributor

Regarding the navigation framework, it was a hard decision for us.
Initially, we used React Native's Navigator but the animations were not smooth enough.

In order to fix this we considered two libraries:
React Native's NavigationExperimental and https://reactnavigation.org/.

We ended up switching to NavigationExperimental because it required a minimum amount of change to the framework and it met our performance goals.

If you want to use a different navigation library, it's possible to extend
https://github.com/Microsoft/reactxp/blob/master/src/native-common/NavigatorCommon.ts

similar to how we wrote delegates for Navigator and NavigationExperimental:
https://github.com/Microsoft/reactxp/blob/master/src/native-common/NavigatorStandardDelegate.tsx

https://github.com/Microsoft/reactxp/blob/master/src/native-common/NavigatorExperimentalDelegate.tsx

Unfortunately, ExperimentalDelegate does not currently work with the official version of React Native. In order to support our app's requirements, we made some enhancements to NavigationExperimental which haven't yet been contributed back to Facebook's React Native repo. The primary enhancements are a fade navigation animation (similar to Navigator's) and the ability to provide custom navigation animations.

Also, ExperimentalNavigator got deprecated and pulled out from the ReactNative repository, so likely we will move our implementation to the separate reactxp plugin.

Our goal was to create a cross-platform framework. Currently, Facebook's NavigationExperimental seems like a reasonable choice as it results in smooth animations in our app and we are able to share navigation code between all platforms Skype is working on.

@fotiDim
Copy link

fotiDim commented Apr 10, 2017

@dryganets whatever your reasons back then the way to go now is react navigation. If it doesn't support UWP you can consider contributing that part maybe.

@dryganets
Copy link
Contributor

dryganets commented Apr 10, 2017

@fotiDim we have nothing to argue about 🤣

I took a closer look at the https://github.com/react-community/react-navigation.
It's the framework we likely will use once we move to react-native 0.42. I can't give any timeframe now as it could change with our project priorities.

In fact, https://reactnavigation.org/ just an ExperimentalNavigation pulled out of the facebook repository into the community one.

I was likely looking into the different library before. It was fully native and that was a limitation for us as we need full control over the navigation stack to have a compatibility with the web/desktop version.

The ReactNative community is fluid and fast growing. Projects often change authors and names :)

We are not trying to limit anyone. Navigation framework choice it's probably the hardest decision in case you are building a cross-platform app as many future architectural decisions would depend on it.

@smkhalsa
Copy link

smkhalsa commented May 5, 2017

@dryganets any update on when we can expect the update to react-navigation?

@quantuminformation
Copy link

I started a RN app using react-navigation, but I think I will wait a bit before continuing as I would like to build with XP. Exciting stuff!

@dryganets
Copy link
Contributor

@smkhalsa, we don't have exact plans for this enhancement yet, sorry.

@afilp
Copy link

afilp commented May 10, 2017

@dryganets Can we use react-native-router-flux with reactXP?

@quantuminformation
Copy link

Any updates guys?

@quantuminformation
Copy link

I had to google UWP, not something that most js devs would worry about..

@erictraut
Copy link
Contributor

We haven't forgotten about this. There are still several items that are higher on the priority list though.

@LeJPR
Copy link

LeJPR commented May 24, 2017

The core of react-navigation works fine with reactxp, to get it running as is you just need to create reactxp versions of the views used by the different navigator types such as stack/drawer/tab. In doing this though i ran into some challenges with the parity of reactxp animation vs react-native. Unless i'm mistaken it seems there's some quite fundamental limitations with reactxp animation currently - from what i can see you can only have a single interpolation off an animated value (add another and it will overwrite the first), only two values in an interpolation array (as opposed to multiple steps). This functionality is used extensively in the react-navigation views for native like experience. To get around this (driven by a lack of time to consider how to reimplement with reactxp animation) i ended up patching in animatedjs for use on reactxp web navigation views, which provides parity with react-native. Kind of leads me to believe considering animation might be a precursor to react-navigation/more important question. Happy to put up a sample of the above approach to getting react-navigation working with reactxp if of benefit - definitely just for awareness and not production use though!

@erictraut
Copy link
Contributor

@LeJPR - thanks for investigating. Yeah, it would be useful to see what you've done. Perhaps you can check it into a branch?

@LeJPR
Copy link

LeJPR commented May 25, 2017

will try and grab a few hours of the weekend and get an example up. Great library by the way - i've been refactoring a reasonably complex react-native app into reactxp and have been really impressed with the experience.

@LeJPR
Copy link

LeJPR commented May 26, 2017

have dropped an example at https://github.com/LeJPR/reactxp-navigation-example.

Built reactxp-navigation and reactxp-animation as extensions which i've also published github.

@LeJPR
Copy link

LeJPR commented May 30, 2017

Eric - off topic a bit for this thread, but would you be open to a PR on animated? If so I'll see if I can figure out how to implement things like multiple animated transforms on a style, multiple interpolations on a value etc.

@erictraut
Copy link
Contributor

@LeJPR, yes, I'm open to it. We've had it on our list for a while, but it's never a high enough priority. If you have time to make improvements to the web implementation of Animated, that would be great. There's a possibility we could reuse some/all of the implementation in react-native-web. I haven't investigated it yet.

@housseindjirdeh
Copy link

Just wanted to ask, with the current Navigator is it possible to render a header navbar or a tab bar of any sort? The documentation and sample apps cover 2-3 card stack flows so will this functionality only be available once react-navigation is leveraged?

@dryganets
Copy link
Contributor

@housseindjirdeh we have a separate control for rendering tab views. It is not open sourced yet.
You could use the tab view as a scene for the navigator.

@MovingGifts
Copy link
Contributor

@dryganets When do you guys plan on open sourcing it? Can you share how to add the tabs based on your suggestion?

@erictraut
Copy link
Contributor

We don't currently have any plans to open-source this component. It has a bunch of complicated features that are specific to the Skype client.

@MovingGifts
Copy link
Contributor

@erictraut Is it possible to have tabs on the bottom (like react-navigation's) tab navigator? I am not sure how to implement that with ReactXP.

@erictraut
Copy link
Contributor

erictraut commented Jun 16, 2017

What functionality are you specifically looking for? Do you need the ability to swipe left/right between tabs? Or are you just looking for a group of tab buttons that selects one of n content panels based on the currently-selected tab? If it's the latter, it's trivial to implement in ReactXP. If you need swiping, it's still possible to implement using ReactXP's GestureView, but it's a bit more involved.

@MovingGifts
Copy link
Contributor

MovingGifts commented Jun 16, 2017

Yep, the latter :) I didn't see any examples, so wasn't sure how to implement it. So for me coming from React Navigation, we had a Drawer on the left, and Tabs with icons on the bottom (currently selected tab with active icon). I am trying to implement both in ReactXP, but didn't see any examples on how to do that. That's why I am asking here so I can move over my app to React XP and have the same functionality :)

Ideally, a react-navigation integration would remedy the need of a different approach and would attract many others that use rn library. Unfortunately, the support on react-navigation is almost non-existent for the last few weeks...

But moving forward, how can we implement a drawer + tabs with ReactXP. Any code examples we can implement at this point?

@erictraut
Copy link
Contributor

If you don't need swiping, then you can easily create your own tab bar component that renders the tab bar buttons any way you want. Then lay it out as follows, positioning it below the panel.

render() {
<RX.View>
    { this._renderPanel(this.state.selectedPanel) }
    <MyTabBar
        buttonList={ buttons }
        selectedButton={ this.state.selectedPanel }
        onPressButton={ this._onPressButton }
     />
<RX.View>
}

@agrcrobles
Copy link

Thanks for sharing the options @erictraut !
I think navigation should be plugged into ReactXP, I find it more flexible and I think it scales better.

@MovingGifts
Copy link
Contributor

Thank you for sharing your thoughts and status with us @LeJPR and @erictraut!

@agrcrobles which option number are you referring to for flexibility and scaling better?

@agrcrobles
Copy link

My vote goes to 2. :)

@MovingGifts
Copy link
Contributor

MovingGifts commented Jun 21, 2017

I am confused with the options :)

But I think there are 2 parts to this:

  1. Defining StackNavigator in central location in a file routes.js
import { StackNavigator } from 'react-navigation';

const BasicApp = StackNavigator({
  Main: {screen: MainScreen},
  Profile: {screen: ProfileScreen},
});

Along with the screen names, some routes will define modal mode to show the sliding up of the screen, a path for the location, and some will have params (at a minimum) This route can be used and not have to worry about TabNavigator and DrawerNavigator, and we can implement those manually with JS (or they can be carried over, not really sure about the complexity there/cross platformness). For example, their current DrawerNavigator does not push content, only overlays, and you can't customize the overlay color, so I feel like the manual implementation may be better in this case. I think TabNavigator may also pose some issues with cross platforms, since we may want the bottom tabs on mobile, but no tabs and instead link/icon in very different locations on web, but I think with the current implementation you wrap all scenes you want as tabs in a TabNavigator, so how to split it out on web if you don't want those scenes as mobile like tabs? For that, I think also a custom js component implementation as shown above by you would work really well on a StackNavigator that needs tabs:

render() {
<RX.View>
    { this._renderPanel(this.state.selectedPanel) }
    <MyTabBar
        buttonList={ buttons }
        selectedButton={ this.state.selectedPanel }
        onPressButton={ this._onPressButton }
     />
<RX.View>
}
  1. Navigating the screens
const { navigate } = this.props.navigation;
return <Button title="Go to Jane's profile" onPress={() => navigate('Profile', { name: 'Jane' })} />;

One issue I came across with this is I had to always keep passing the navigate prop everywhere, which was a real pain, instead of using it from a centralized store. Luckily I came across this which worked really well and I only needed to import the store in the scene and was able to use it like this:

import navigationStore from 'stores/navigation-store'
return <Button title="Go to Jane's profile" onPress={() => navigationStore.navigate('Profile', { name: 'Jane' })} />;

I think the navigation syntax across all platforms should work the same way, via a navigation store as opposed to a prop being passed all the time.

I am not sure at this point, if there should just be one routes.js to handle all the navigating, vs having routes.js (for native) and routes-web.js, and depending on the visiting Platform it would use the correct file, but if the web version does not exist, only the routes.js will be used for all navigation links.

Those are my thoughts so far, but not sure which option they fall under :)

@LeJPR
Copy link

LeJPR commented Jun 22, 2017

I'd vote somewhere between 2 & 3! Preferred Navigation options on react-native don't really have a history of being stable.. so baking it into the RX namespace might cause a headache in the future...as it has now. If there were pluggable options i might start a new project today using an RX extension built on react-navigation, or react-router. In 12 months time if i were to start a project...perhaps airbnb's native-navigation will have web as well, or react-universal-new-fangled-navigation will be flavour of the month. I think at the end your point re: larger form factors is valid as well - in reality i think navigation is one area people will need to get their hands a little dirty, and even if a 'generic' approach were provided, for most apps you're going to need to do some custom stuff to cover all form factors.

@MovingGifts
Copy link
Contributor

At this moment, it's like the react-navigation maintainers aren't around.. It has been 2 months since their aimed v1 stable release, and started collecting v2 features from users, but no word on v1 stable release update at all (and they're just leaving people hanging, which is not good).

It's really annoying that they start off with great enthusiasm to make the "best" react navigation system and then ignore so many issues and dont' look at open PRs. I worry that if we integrate it with ReactXP, it would be the weakest part of ReactXP if it's 100% dependant on react-navigation (solely because of the lack of maintaining the library and no response from the maintainers for a long time now).

I really like their API though for its simplicity, but it's also missing some key things like replacing a current scene for example, and issues with drawer/tab navigators.

My thoughts are to use their StackNavigator api, or at least the same syntax, but leave out problematic areas such as the other navigators, and instead add them manually as js component in the views with code. If animations were an issue as @LeJPR said, then maybe looking into the areas he was referring to regarding animations, so everything looks correct.

I really like ReactXP and their mission and support, and it would be awesome to integrate the StackNavigator API + add few minor custom things, like the replacing of current scene for example.

@quantuminformation
Copy link

I'm sure it will happen.

@pillowsoft
Copy link

I vote for 2....this could be yet another possible abstraction/api: react-router-navigation...just looking at it now, to see what it would take to port it to RXP

@erictraut
Copy link
Contributor

After completing our internal prototyping, I think we're going to go with option #3 for now, with an eye toward #2 or #1 at some point in the future. That means we'll be removing the RX.Navigator namespace and corresponding functionality from ReactXP in the next version. If you want to use stack-based navigation in your RN app, you'll need to choose from among the various options available.

Now that we've made this decision, we are unblocked from moving ReactXP to the latest version of React Native (0.46).

@MovingGifts
Copy link
Contributor

@erictraut Just wondering... Any idea when the ETA for the next ReactXP version is?

@erictraut
Copy link
Contributor

We've continued to publish new minor versions on a pretty regular basis — whenever there are bug fixes that have been pushed. Currently, there are no submitted changes that have not already been published.

If you're asking about an ETA for the next major version, it will probably be at least two weeks, maybe three. The developer who has been at the center of this work is currently on vacation.

@MovingGifts
Copy link
Contributor

MovingGifts commented Jul 11, 2017

Thank you for the quick update.

Yup it was about the next major version to use react navigation :)

@MovingGifts
Copy link
Contributor

Just wondering if anyone was able to get react-navigation working on web as well? I got it working on mobile, but I am starting to look into react-router v4 as an alternative since I can't get react-navigation working on web (I am okay with having a separate routes file for mobile/web) as opposed to a single file, but just can't seem to get it to work with my ReactXP web portion of the project.

Does anyone have react-navigation working with the web portion of their XP app as a separate routing file?

@vicentedealencar
Copy link

@MovingGifts I just found this out, maybe it helps you react-router-navigation

@quantuminformation
Copy link

Is anyone aware of any over reactxp and create-react-native-app. I'm trying to decide which one to use.

@MovingGifts
Copy link
Contributor

@vicentedealencar Yup, I saw that mentioned by @pillowsoft a few comments above. Does it work for both platforms for you guys on ReactXP?

@quantuminformation I was thinking the same with ReactXP and create react app, since CRA is zero configuration, so many things have already been done for any app wanting to use it out of the box, not sure if they can work together (having CRA run the web portion of things). I haven't used it though, just using create-xp-app at the moment. I wonder if anyone here is using both? It would be great if it was also zero config with ReactXP as well, so we can focus on just the app code :)

@Roba1993
Copy link

Is there any solution how to continue with routing, when this feature will be removed from reactxp? In my opinion a common, simple, cross-platform routing functionality is needed.

@Fitzpasd
Copy link
Contributor

@LeJPR - Are you working on a PR to integrate Animated.js?

@quantuminformation
Copy link

@MovingGifts I've dropped all react native dev for now as the platform is still too unstable for me.

@MovingGifts
Copy link
Contributor

@Roba1993 I hope some examples/documentation emerges on how to route within a ReactXP app for both mobile/web platforms (ideally using a single API). Atm, I don't think anything exists yet.

@quantuminformation You can check out Expo (no web). I feel your frustration though, I am really not happy specially with routing and all the cumbersome configs. I just want to code my app views with simple routing for mobile/web, push to production easily (app stores/push to online server) and be done! I guarantee within a few years, it will all be drag and drop to build for different platforms, with routing built in, pushing to production, and everything will be so easy. But until then, we gotta grind or drop it..

@quantuminformation
Copy link

quantuminformation commented Jul 18, 2017

My biggest gripe is all the random build errors like bundlejs and npm etc. Whether its CRA, RN or ReactXP. I'm going for PWA's for now.

@LeJPR
Copy link

LeJPR commented Jul 25, 2017

@Fitzpasd - did a prototype of using animatedjs for reactxp animation, however at this stage will not be submitting PR. From the looks of it the animatedjs repo is no longer actively worked on - taking some of the concepts and building out reactxp animated is probably the way to go I would think.

@MovingGifts
Copy link
Contributor

I currently have ReactXP working on mobile with react-navigation, but can't seem to get it to work on web. I don't really need animations for web, but just to be able to pull in params if they exist in the url and use url paths to navigate to their mapped components.

Can someone share with us how to get react-navigation working on web? Their docs are very sparse and lack important details for web integration. There are also many open issues regarding web integration in their repo, but no responses, so it seems impossible to get a solution there.

@LeJPR
Copy link

LeJPR commented Aug 3, 2017

@MovingGifts -probably a bit off topic for here. But to summarise they don't provide 'out of the box' navigators/views for web - you have to create your own. In short I don't think you're going to get a 'magic bullet' for navigation Multiplatform.

@MovingGifts
Copy link
Contributor

@LeJPR Thanks for your feedback. Looks like react-router it is for web.

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

No branches or pull requests