Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do react native uses same code for ios and android or both platform code should be written separately?

Hi i have very good experience in working on Cordova with Ionic Framework and some other frameworks. Personally i m not happy with Ionic performance so i m planning to switch to React Native from Ionic.

I just want to know few things before switching. On Cordova project when you write an app for android same code will be used for ios and windows. So it saves lots of code writing. You just have to add the platform with one line command. But i m not sure about React.

Do same thing happens in React Native? Android and Ios uses same code with different platform or we have to write all code for another platform or some percent of the code are shared?

Also Ionic framework comes with lots of components and pre built UIs. Do react native also offers UIs and components?

Should i learn React js first to start React Native or i can learn React Native and React Js together?

Can we use React Native code for web platform?

like image 777
Krishna Karki Avatar asked Aug 02 '16 12:08

Krishna Karki


People also ask

Is React Native code same for Android and iOS?

With React Native, developers can write real, natively rendering mobile applications for iOS and Android. It helps build apps on two platforms at once, while maintaining the look, feel, and productivity of an app built on the specific iOS or Android platform.

Can we combine native iOS or Android code in React Native?

Yes, we can combine Android or iOS code in react native. React Native helps to smoothly combines the components written in Java, Objective-C or Swift.

Is coding in react the same as React Native?

React Native is an open-source JavaScript framework used for developing a mobile application for iOS Android, and Windows. It uses only JavaScript to build a cross-platform mobile app. React Native is same as React, but it uses native components instead of using web components as building blocks.

Can you make iOS and Android apps with React Native?

React Native enables you to build iOS and Android mobile apps and benefit from code reuse cross platform. React Native is an exciting new language backed by Facebook that allows you to create a native mobile experience on Android and iOS devices through a common coding experience.


1 Answers

So, let us start with the React Native slogan "Learn once, write anywhere". This pretty much answers your first question. You have to write code both for your android app and your iOS app. This is because android and iOS have different native components. You can reuse some of your code like logic, how to distribute data (for the most) etc, but you will have to tune this to work with the native components of both android and iOS. EDIT: This was the practice before, but is outdated now since you now only need to write it once

Second question. React Native enables you to utilize a lot of already well known components. Also the community enables different other components if it is not in what Facebook already have released. If you for some reason want something no one have made a port for, you will need to do some native programming to enable such a component.

Third question. The best is of course to learn React first, but you can easily learn React as you code React Native. React Native Playground is a nice place to play around with React Native. EDIT: RN Playground is no longer active, but there are other places to play with RN like Expo. Again, this depends on how you like to learn new frameworks and languages.

Fourth question. No you can not use React Native code as a web app. This is because your React Native app will be using native components. In iOS you use <View /> which is the same as <div /> (Pretty much). This does not mean you are not empty handed if you want to create a web app afterwards. You can use parts of your layout and re-write them to work on the web. Like translating view to div, image to img etc.

gl

like image 120
magnudae Avatar answered Sep 20 '22 05:09

magnudae