Tricks and Tips for Developing with React Native
This is the second post in a series that serves as an expanded edition of a talk my team gave at a meetup with the NYC JavaScript React Group.
React Native is an exciting new framework for building native applications, but of course with anything new there is a learning curve. We wanted to share the lessons we learned while developing our companyâs first native app, ThisAM, utilizing React Native.
When our company, Refinery29, a large lifestyle-oriented digital media brand, decided to make its first native app back in mid 2015, we thought it was a cool opportunity to explore something that was brewing in the developer community.
In January 2015, Facebook released React Native, a JavaScript framework for creating native applications for both iOS and Android. The possibility of being able to build a native app utilizing the same skills and language weâve already honed to create our web experiences was intriguing.
Furthermore, the app itself, ThisAM, is a great candidate for this new approach as it is designed to be very minimalist. ThisAM is a simple daily rundown of everything you need to start off your day with a fresh editorial eye. Itâs simple, beautiful, and parses down the essential news of the day in a delightful way. Download the app here to see if you agree. But not everything went smoothly. It would have been awesome to work with an established framework, with polished versions, using tricks and tips from the community that were well-documented. Instead, we were facing a situation where a new stable version was released every two week or so, for a framework that was only recently established (React.jsâââ2013, React Native -2015), and with a community that has different priorities than we do.
We still believe that React Native is the future of native app development. If you are a developer and are interested in learning how to work in React Native while it is still getting its sea legs, here is a rundown of our most important learnings.
Weâve had to scale down our Google Analytics expectations over the course of building ThisAM. We started by forking React Native Google Analytics in order to add support for custom dimensions. This worked really well for us until we realized that the returning users werenât being recognized because the libraryâs getClientId() implementation was returning a new user ID every time. Weâve since solved this problem with the help of a library called React Native Device Info. DeviceInfo.getUniqueID() generates a consistent, unique ID for each user and is currently the community-recommended solution for this problem.
When we first started development way back in July of 2015, we used React Native Webpack Server instead of the default React Packager. To make matters worse, we forked React Native Webpack Server. This turned out to be a mistake because RNWS was abandoned in favor of the default packager and we had to switch back when upgrading our React Native version. Bottom line: stick with the default React Packager.
In terms of testing, hereâs where we landed. For the full rundown on tests, check out this post from my colleague. âââJest for unit tests â Calabash for feature tests â Running both unit tests and feature tests in full on Travis CI
Donât be shy about using third-party libraries, especially if you are more comfortable with JavaScript than Objective-C. Forking and building functionality yourself is out of the question if you want to continue to upgrade and take advantage of new featuresââânot to mention community support.
Keep on eye on the community and their release notes, and make sure to upvote or submit your requests on Product Pains. The more feedback we give contributors, the more they can âReactâ (hehe) to the needs of the community.
In all, we are proud and excited to have built our app in React Native. We hope these tips can help you smooth out some of the rougher patches of utilizing an exciting new technology. You can also read more about my teamâs product and testing strategies if youâre interested.
Thanks for reading, and please contact me at [email protected] with any questions.










