Why React Native Has Split Opinions | Swift for JavaScript Developers Course

Why React Native Has Split Opinions

I believe React Native is still the most cost-effective way for developers and businesses to build cross-platform apps in 2022 across iOS, Android and Web.

Posted By Adam Bulmer

With advancements in component libraries, it is now possible to share React Native components on the web with libraries such as tamagui.dev and React Native Web.

React Native has a promise to "learn once and write anywhere". That promise is perfect for app developers who are targeting multiple platforms but it's also great for web developers who are already familiar with React on the web because a lot of the core API's are the same.

Since 2015 when React Native was first announced their has been split opinions on the longevity of React Native with companies moving to and from React Native. Companies such as AirBnB have publicly announced why they were moving away from React Native and companies like Shopify and Coinbase announcing why React Native is the future of their app platforms.

Why the Split Opinion

I think developers and companies misinterpret the "learn once and write anywhere" promise and think it means "write once work everywhere". The problem with this thinking is it causes frustration when a developer realises a piece of code written in React Native can't be shared across platforms. Each platform have their own set of API's, patterns and UI components that don't make sense when you start sharing code.

Take for example HomeKit on iOS, this is an API Apple have provided to let people communicate with and control connected accessories in their home using your app. Google have their own set of APIs but they are fundamentally different in how they work.

Developers try to solve this problem by abstracting platform APIs into a shared common interface but this requires native domain knowledge for both iOS and Android often creating leaky or wrong abstractions.

Teams using React Native have likely been hired from a web background and will find it difficult when they don’t have someone to help with those native platform APIs, React Native upgrades or native dependency management.

To use React Native effectively, developers and teams have to invest time into learning the individual native platform APIs and languages so that they can get the best out of the platform.

Individual developers and teams should aim to become less reliant on 3rd party libraries that may be slow to update as the underlying platform changes. This means learning swift, Kotlin and if you're integrating React Native into a legacy app, perhaps Objective-C and Java.

What is the point in React Native

At this point, you may be wondering why bother with React Native if you have to learn the native languages and APIs as well?

React Native does allow you to share code between platforms but it does not allow you to "write once work everywhere". You can share common helpers and business logic between platforms by abstracting code into reusable chunks of code. It is only the code at a boundary between a Native API and React Native code that will require some form of native platform knowledge.

Another thing to consider with React Native, Apple and Google have made huge commitments to their UI Frameworks using React as inspiration. In 2019 Apple announced SwiftUI, a declarive UI framework for iOS and macOS. Google also released Jetpack Compose for Android. By using the native UI frameworks and React Native for common helpers and business logic, you get the performance benefits of the native platform and the reusablity of code across platforms.

Conclusion

React Native is not a magic pill, you will need to understand the native platform APIs and languages to be successful. React Native and the UI Frameworks like SwiftUI and Jetpack Compose aren't exclusive to each other and could co-exist together within a codebase.

Subscribe To The Newsletter

If you want to create your first native app or have just begun your native app development journey, be sure to sign up to the newsletter. No Spam