8

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?

Krishna Karki
  • 749
  • 12
  • 31

1 Answers1

14

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

magnudae
  • 1,272
  • 2
  • 13
  • 32
  • Thank you, you answered very well. – Krishna Karki Aug 02 '16 at 12:56
  • 1
    Want to add that the first point is a bit outdated in 2018. There are still platform specific components, but React Native now supports that you write one app due that they have a quite large set of components which can be utilised on both platforms. – magnudae Feb 28 '18 at 10:55
  • 1
    Very well answered. Just Edit the first part as it does not hold true in 2018. – Ashish Yadav Oct 12 '18 at 04:18