WhoBuilt

Integrating React Native into an existing native codebase

Sep 14, 2018· 24 min· 302 views·Watch on YouTube

Speaker

Eloy Durán, an iOS developer at Artsy and a React Native contributor, explains how Artsy integrated React Native into its existing Eigen iOS app at a Callstack event.

Why Artsy adopted React Native

Artsy was falling behind its web product because native releases took longer. The team wanted a simpler way to structure views, faster iteration, better networking with GraphQL, and shared work across web and mobile. React Native also offered a path toward an Android app.

Packaging React Native for a native app

Artsy put its React Native code in a separate repository called Omission, packaged as a CocoaPods dependency for the Eigen app. Eigen starts the React Native bridge and presents exported view controllers through its existing router, Switchboard, without needing to know React Native is running. Separate repositories and CI made onboarding and tooling easier, but added release, testing, and coordination overhead.

Bridging navigation and native behavior

Omission exposes a native callback so React Native screens can send URLs to Switchboard and move among React Native, native, and web views. For nested scroll views, Artsy patched the native implementation to detect enclosing scroll views and forward scroll events with adjusted coordinates. This let JavaScript components paginate without handling the nesting themselves.

Sharing image infrastructure and accepting tradeoffs

Artsy reused the app's SDWebImage cache so native and React Native views could share images, and drew artwork into opaque contexts to reduce compositing work. Durán says the approach worked in production, but teams should expect native engineering when designs cannot adapt to framework limits. He also cautions that adopting React Native means taking responsibility for its bugs and dependencies.

Takeaways

  • Keep React Native behind native view controllers when you want to add it without changing the host app's workflow.
  • A separate repository can simplify onboarding and tooling, but plan for extra release, testing, and issue-triage work.
  • Use native bridges to connect React Native screens with existing routers and platform capabilities.
  • Expect to build native workarounds when product requirements exceed framework defaults.
  • Adopt a large open source dependency only if the team can maintain it and fix issues it encounters.

Mentioned in this talk

Search inside this talk

What was claimed 12

Related talks