kadaj kadaj - 5 months ago 28
Android Question

Does the UI layer change between iOS and Android in React Native?

I am just exploring react and have couple of doubts. I don't see common UI components for react native apart from scroll, flexbox, input list in the documentation. So if I am writing for iOS will the UI part be different from that of Android? If I am having a web app written in react, can I reuse it (no div, img etc for react native)? So is there any possibility of reusing the web UI to native UI? So how exactly is it cross platform? I can reuse the logic only, right? Thanks.


If you are writing an app for both iOS and Android in React Native you will be able to share about 90% (or more) of the UI between the two platforms.

If you look at the documentation you will see that only some UI components are postfixed with iOS or Android. Those are for views that are specific to each platform and cannot be merged into a single React view that will map automatically to it's native counterpart, for example DrawerLayoutAndroid, which is specific on Android.

On the other hand generic views like View, Image, Button, Text, TextInput and so on, are cross platform, so you can maintain the same UI code between the two platforms. The only place where you will branch your code is if you want to implement a platform specific UI with it's specific components.

I never tried reusing a React Web UI on Mobile, but I assume that if you're not using components such as div, img it should be doable with small tweaks.

I hope this answers at least part of your question.