Over the last year I've been learning and developing mobile apps using React Native. Now it's 2018 and I'd like to reflect on my experience and give my opinion on some of the best and worst bits.
Photo by Blake Connally on Unsplash
Platform Code Sharing
"Learn once, write everywhere" - This is often used as one of the main selling point of React Native. You can share the majority of your code across both platforms which is great for business logic but not necessarily for UI. You can of course using conditionals to render different components for each platform. This means that you don't have developers that can only work on the Android or iOS app and should lead to time being saved and less developers required (though for us, that might be a bad thing...)
Hot Reloading & Speed of Development
My favourite feature. I can build a UI really quickly using flexbox and see the changes in real time as I save files. Compare that to Xcode where you have to rebuild the app each time and then have to navigate to the screen you were working on (though it does have Interface Builder...).
No obvious issues. Haven't tested it but seems to hold up well with our use case - not a lot of data or high performance requirements. Animations are usually super smooth and even allow you to hand them off to the native side of the bridge for even better performance. You can't always drive animations natively though and some interactions can be a bit jittery but that usually comes down to poor implementation rather than a performance bottleneck by React Native.
Setting up a new project is fairly straightforward especially if you use Expo and/or create-react-native-app. It gets messy once you start having to fiddle with native project configuration.
react-link does a good job most of the time when adding new packages but doesn't always work meaning you'll have to dive into native projects from time to time.
Community & Ecosystem
The community is huge and there is a lot of support for React Native. That means there's a lot of open source components and libraries to use.
Honestly I haven't gotten into testing nearly as much as I should have but the little I've done has been fairly straightforward. I've used Jest and Enzyme that have decent documentation and guides to get started. Jest's snapshot feature is awesome and only takes a couple of lines of code.
Don't even bother getting into build tools or using fancy features that require you to start messing around with babel plugins. If you're fairly experienced then sure go ahead but if you're still learning React and ES6 then it's just another thing to worry about that just isn't worth it.
React Native doesn't give you everything out of the box so if there's a feature you want to use that isn't supported then you'll either need to use a third-party library or build it yourself.
Because we're abstracting other platforms any new features that are added need to be implemented in React Native. A perfect example is the new iOS 11 large nav bar titles. That feature is 1 line of code in Swift:
self.navigationController.navigationBar.prefersLargeTitles = true
react-navigation) then it's definitely not a trivial addition.
Sure you can implement it yourself and contribute back to the community, thats the great part of open source. But if it's been built once by Apple I just want to use it and get on with making great apps, not reimplementing functionality.
Many people may disagree with my opinion on this one and I may change my mind in the future but that's something that bothers me at the moment.
This is my #1 biggest issue with React Native at the moment. Navigation is a f***ing disaster. There are too many competing solutions and the suggested library
react-navigation isn't even production ready. There is no perfect solution so it's always a compromise which to choose:
react-native-navigationby Wix is 100% native so you get all of the platform controllers and animations for free. The way it integrates with native projects though means there are some things you can't do - e.g. you can't create iOS share extensions. It also has a weird API and doesn't handle deep links very nicely.
native-navigationby AirBnB is also 100% native and probably has the nicest API of them all. However, it seems like the team at AirBnB aren't actively maintaining it and there's some planning going on about migrating it to become a community lead library. Either way it's future is uncertain so not production ready.
There are other libraries that I haven't really used -
react-native-router-flux and probably more. That's part of the problem.
Errors are hit and miss which is seriously frustrating. Sometimes they point you directly to the issue, otherwise it's a minefield and they make no sense. I've lost half (sometimes entire) days tracking down issues, upgrading the React Native version, finding bugs in third-party libraries, etc.
There are a lot more pros than cons to React Native. It's the best solution yet for achieving a truly cross-platform development experience. That's great for startups because you're moving quickly, don't have a lot of resources and can share developers across platforms saving time and money. It's got some great features that I've mentioned above which I'd love to see make their way into Xcode (doubtful..).
That said there are still some serious compromises that need to be made which you may not always be aware of until further down the line. You can argue about whether or not it can truly replace native development. Recently the iPhone X was released. Apps built natively that supported Auto Layout automatically adapted to accommodate the new screen layout. The React Native community had to spend more time adding support for those new accommodations.
It comes down to your business needs and whether you want to be ready for new products and platform features.