Introducing React Navigation for React Native
reactnavigation.org
reactnavigation.org
In my experience this was one of the worst parts about using React Native - that there wasn't a simple, easy router (like React Router for web).
Looking at the GitHub repo (https://github.com/react-community/react-navigation), it looks like this was a collaboration between FB engineers, Exponent (great product + team!), and the open source community. So thankful for these incredibly smart folks working on software we can all use for free. <3
https://medium.com/@jschloer/react-router-v4-with-react-nati...
https://react-router.now.sh/MemoryRouter
One of my clients uses react-router for web and we are exploring reusing it in our react-native apps.
I'm part of a group working together on a project to teach ourselves coding so if anybody has any existing solution or alternatives, please share!
https://github.com/ReactTraining/react-router https://react-router.now.sh/MemoryRouter https://medium.com/@jschloer/react-router-v4-with-react-nati...
Navigation is a big pain point for sharing code between web and native.
A cursory look show that the parent project does not use a native navigation bar on Android. NavBar buttons look pretty bad. RNN linked above uses native NavBar/NavBarButtons on both platforms and looks much better.
But RNN comes with it's downsides. It's under heavy development. It's less of a community project (wix offers it up but doesn't take community patches much).
The main difference in the goals is that react-navigation is intended to be entirely cross-platform, including iOS, Android, ReactVR, and web. It's implemented entirely in JavaScript which has a huge upside because you can ship updates to it OTA and you can submit patches without needing to know ObjC/Java and the platform's respective navigation APIs. It will be an important library to push forward development of more powerful general purpose native APIs, for example the native driver for Animated was built with the intention of making it possible to run navigation transitions on the UI thread. Similarly, this will be an important use case for a better gesture API (https://twitter.com/notbrent/status/824683858037649408). I wrote more about why we should try to use JavaScript as much as possible with React Native here: https://blog.getexponent.com/good-practices-why-you-should-u...
OTOH, if what you need is a navigation library that is 100% faithful to the platform's built-in APIs, and you need that right now, then you will probably want to use something like react-native-navigation (Airbnb is working on open sourcing a similar library that they use in their app).
Pros/Cons?
I think the biggest pros of react native are:
1) Not having to compile to see UI/Business logic changes (Swift compiler is slow).
2) The ability to push changes over the air after you switch.
3) Large parts of your app just work cross platform with minimal changes (I've shipped two iOS/Android apps).
4) If you have a react web team, they can now review and help out with your mobile apps.
5) It's easy to keep product in synch across multiple platforms (i.e android/iOS release at the same time).
I think the big cons are:
1) It's Javascript.. ES6 + babel makes this a lot less terrible than it was in the days of web apps wrapped as native apps but it's still Javascript.
2) If you have to do long running background tasks (network polling, bluetooth, music, location, etc) you basically have to do it in native code. This can be a big architectural pain in the ass depending on what your app does.
3) Ramp up time. Learning about React and all the third party libraries (Redux, etc) you will need to be productive takes time.
4) Cross platform testing. I.e if you share code with your web/android engineers, they will need to be disciplined about not breaking things (npm and versioned shared libraries helps with this).
5) Third party library quality in Javascript land can vary a lot. This requires you spend quite a bit of time vetting them.
If your based in the Bay Area I'm going to be giving a talk on on some of this in March.
it works pretty well, but havent done anything other than syncing and notification pushing. other API s should work
"the workers are paused when the app enters in the background the workers are resumed once the app is running in the foreground"
This won't work when your app is backgrounded or if the screen is locked.
EDIT - this fork looks like a good bet: https://github.com/ZhijieWang/react-native-workers
Most apps I work on, and projects I see, could benefit from React Native.
The actually innovative ones, on the other hand, could not.
New view controllers continually being introduced by Apple and Google are not available in React Native. So if you want to get fancy with UX, you are out of luck. Or won't get a net benefit when you start doing native development to get around the limits of React Native.
If your app just pulls lists of items from a server and displays them, with pull to refresh and infinite scrolling being the most innovative parts? You should probably use React Native at this point in time.
Almost all of the "showcase" apps written in React Native (hosted on the Facebook page) aren't convincing showcases. Either because their UI is pretty bad / simple, or because they have only released on one platform. Townske is a pretty good example though.
1) An example: It wasn't too long after iMessage apps came out in iOS 10 that tutorials emerged telling you how to use react native to build them, see:
https://medium.com/rendez-voo/messages-app-app-extension-ios...
2) It's really not that difficult to wrap native components and expose them to react native, see:
https://facebook.github.io/react-native/docs/communication-i...
I would say that Android is a little bit more work right now, but it's really not that big of deal.
3) It's easy to embed react native in an existing iOS app. This is great for things like sign up screens, call to action pop ups or other Areas of the app where you want to iterate quickly.
Also animations with react native are pretty nice. I haven't come across anything that I haven't been able to do yet. See:
https://medium.com/react-native-training/react-native-animat...
The biggest issue with react native is that its Javascript which a lot of native developers don't really like especially when compared to Swift.
It looks like this problem is acknowledged and addressed by the React Native folks[1] : React Native has several of the most critical platform components already wrapped, like ScrollView and TextInput, but not all of them, and certainly not ones you might have written yourself for a previous app. Fortunately, it's quite easy to wrap up these existing components for seamless integration with your React Native application.
If your app has some innovative UI, but you can reuse most of the code from React Native for some basic parts of the app, wouldn't you benefit from using React Native? Or is [1] not that "quite easy" ?
If you plan to have your app run on both iOS and Android (and Windows 10), what is the downside of React Native?
I wonder how React Native stands vs. Cordova and Xamarin, performance wise and ease-of-use. I'm thinking it falls somewhere in between Cordova and Xamarin, but I'd love to hear people's experience on this.
[1] https://facebook.github.io/react-native/docs/native-componen...
Cons: - Fast moving project that is constantly updating (good and bad). Can be hard to keep updated and upgrading can be a pain - Documentation is ok but standard practices are missing
I'm sure other people have others...
But its really hard to argue with getting android as well for almost free, and even having the potential to share code with a web front end as well.
Especially when doing a version 1 of almost anything it seems to make more sense to me than any other option.
I did not have any experience with mobile development or React, and only knew Vanilla JS, none of that new fancy ES6 stuff. I was able to be comfortably effective with React-Native in about a month. On the first weekend, I had a usable sandbox/playground app compiling with hot-reloading enabled which sped learning along in a huge way.
We're a couple hundred hours into that project now, and I still find React Native to be a joy to work with.
Now, I wouldn't say that I'd go 100% of the way with react native, but so far I can say I'll be using it for at least 80% of my layouts/logic.
Is this a web router as well? I think they hinted at that, but it was a little unclear to me. Also, is it really true that react native apps have routing that is too complex for a URI? I can't think of a reason why that is immediately true.
For an example of how this works on web, try browsing to a doc on on reactnavigation.org, then navigate to the home page, and navigate back to 'Docs'. Notice how the state of the docs tab is retained, even though the previous URI had no awareness of that state. Most websites don't behave this way, but mobile apps do.
I'm not saying React and React Native should come included with a router, but that Facebook should provide an official one just like Angular and Vue do.
A good navigation library is the one thing that was missing for React Native and I'm glad to see the collaboration from folks from Facebook and Exponent make this happen.
Unfortunately only for the first few sections, I assume they will be adding more screenshots to the later sections.
They have a Navigator demo app, would be nice if they just put it on the store so we could grab it and just see first hand everything working.
[1] https://reactnavigation.org/docs/navigators/drawer [2] https://reactnavigation.org/docs/navigators/tab
https://github.com/react-community/react-navigation/commits/...
Source: https://reactnavigation.org/blog/2017/1/Introducing-React-Na...
So I would expect that it may well be folded into core react-native in time.
https://github.com/react-community/react-navigation/issues/9
https://github.com/react-community/react-navigation/blob/mas...
Key was to explicitly expose the z-index/component-ordering, so what it does is accepting a "render-list" of compnentName/props/animation triples which it then displays in absolutely positioned AnimatedViews on top of each other.
This way I have good flexibility without introducing metaphors that keep breaking.
React-Router is not an "official" library. As far as I know, neither is React-Navigation.
That said, I also don't know much about the ins and outs of React Native, so there _may_ be some semi-official-ish overlap between React-Navigation and React Native.
(Also, this totally causes an abbreviation clash, as "RN" now has multiple meanings. Oops.)
:)