

React Native — Integrating third-party libraries
source link: https://lambda.grofers.com/interaction-with-the-world-integrating-third-party-react-native-libraries-179384686dc5
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

React Native — Integrating third-party libraries
This blog is part of the Grofers React Native blog series. Here, we attempt to share the journey of integrating React Native into one of India’s largest e-commerce grocery’s web & mobile apps through this series.
We started our React Native Integration to reach a single project that could power all our platforms. We also used the React Native web library for our web platform. In our journey, one of the essential parts of building this system was to choose the right 3rd party integration services that would scale and work across all platforms.
React Native has a large ecosystem of 3rd party libraries but it has its downsides. Some of the major ones are
- Given JavaScript’s nature, the React Native code relies on an engine to interpret and a bridge to communicate with native platforms. This makes features that are built entirely in JS slower than their native counterparts.
- If we use native libraries, the goal of a single codebase powering all platforms cannot be realized.
- Most of the libraries fail to keep up with the latest react native releases and get outdated quickly.
The react-native core provides several features but there are a few use cases that aren’t fully supported. This blog will focus on three such use cases we came across and the solutions we picked.
- Infinite List
- Navigation
- Carousel
Infinite List
Maintaining a consistent frame rate during quick and lengthy scrolls is a challenge even for the native libraries across platforms. As react native communicates with native platforms through the bridge, it becomes difficult to maintain performance across edge cases. This section discusses what the React ecosystem has to offer for rendering long lists with high performance.
What would be an ideal list view?
- Virtualization — Consume less memory by creating or recycling only those views that are currently active.
- Rendering — Can handle 60 fps with fast scrolls
- Lazy Loading — Only load the list items that are visible in the viewport
- Analytics — Can track which list items are in view
- Grid Support — Support for both list and grid view
- Separators — Can render separators among components
Options to consider
What Did We Choose?
There is no obvious choice when it comes to the ideal list view. Scroll View provides a lean solution with all basic features and ease of use but is limited when dealing with long lists. Recycler List View and Flat List are feature-packed solutions but bring forth a complex setup code overhead. Currently, we use Recycler List View at Grofers as it provides significant performance because of its cell recycling feature with long lists. On the other hand, we use Flat List for places that do not require complex list rendering.
Navigation
With a bundle of options and plenty of solutions, navigation in React Native is often confusing. Most of the libraries in the ecosystem are based on natively coded navigation which is like a JS wrapper on Android navigation. Although this can be a great solution if you’re building your solution from scratch, these libraries lose their charm when it comes to brownfield apps. In this section, I would like to talk about the two most popular solutions: React Navigation and React Native Navigation.
Things to Look for
- Performance
- Integration with Native App
- 3rd Party Library Integrations like redux
- Multiple Router Support
- Development Team and community
What Did We Choose?
We planned our migration in phases rather than doing a complete rewrite. One of the most important things for us was brownfield integration which is only provided by react-navigation. Furthermore, react-navigation is one of the best solutions as it is officially recommended by the react-native team and provides the best API support. Additionally, being a JS-only solution, it has a future for web integration and works with most JS libraries like redux.
Carousel
There are no complete cross-platform solutions in react native as JS-driven animations occupy the bridge traffic and slow down the application. Hence a JS-only carousel would not be performant in react native due to heavy animations. Most of the libraries rely on native API-based solutions, making them incompatible with the web.
Things to Look for
- Performance
- Active contributors
- Web Support
- Animation
- Adjacent view
Popular Options
- React Native Swiper - lean solutions for carousels, initially based on view-pager, recently shifted to ScrollView.
- React Native Snap Carousel - Snap carousel is a feature-packed library based on a scroll view and FlatList. It offers a lot of animations and custom features.
What Did We Choose?
Both of these libraries use native APIs to implement animations and do not provide web compatibility. Our use case requires a cross-platform solution, so we use a custom implementation that uses React Native Swiper and React Slick (for web) internally.
Other Libraries
Apart from these some other react-native libraries that we use in our project are
- React Native Tab View for Tab navigation
- React Native Testing Library for Testing
- Redux for State Management
- Axios for API transactions
- SQLite for Database
Tarun is a Software Developer at Grofers. Got questions or have suggestions? Reach out to him at [email protected].
We’re hiring!
We arehiring across various front-end roles! If you are an expert native developer who has never done React-Native before, worry not as we have prepared a proper onboarding guide for you.
If you are interested in exploring working at Grofers, we’d love to hear from you. You can either apply on LinkedIn or directly reach out to the author at the email mentioned above.
Recommend
-
8
Microsoft seeks to build trust in third-party .NET libraries Recognizing that the open source .NET ecosystem is not as strong as it could be, the company wants to work with developers of third-party .NET libraries to impro...
-
6
UI React Native Unofficial SDK for integrating MercadoPago PX Native UIs Jun 16, 2021...
-
10
react-native-braintree-android A react native interface for integrating Braintree's native Drop-in Payment UI for Android using Braintree's v.zero SDK.
-
10
Payments A react native interface for integrating payments using Braintree's v.zero SDK ...
-
8
June Wildeunread,Jun 14, 2021, 3:34:08 PMTo reduce overhead for engineers trying to keep our third party libraries up to date - and to seal the current security patch gap caused by libraries i...
-
9
Integrating Firebase with React NativeFirebase is a Backend as a Service (BaaS) that provides an advantage to mobile developers who use React Native for developing mobile applications. As a React Native developer, by using Firebase y...
-
5
Firebase Authentication Example for React Native Thank you for trying the Firebase Authentication example 👏 Please note that limited support is offered for this example though we will happily accept PRs.
-
6
Integrating third-party APIs into GraphQL with Apollo ClientTo add fast and feature-rich third-party APIs into any codebase, developers need to work within an ecosystem designed...
-
8
rajesh salapu October 28, 2022 5 minute read...
-
6
@ekreative/react-native-braintree Getting started Android Specific Add this to your build.gradle allprojects {...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK