Reputation: 928
I am new to React JS
. I am trying to build a web application which should also work on mobile (Android and IOS) so thought of using react js
for web application
and created few components. so is it possible to use the React js
component in React native
.
Upvotes: 10
Views: 7769
Reputation: 13211
ReactNative is a set of real native Components like View
, TextInput
TouchableHighlight
and more. It is also a platform which let you run javascript code to control these.
There is no WebView like in Cordova, what you get is a native App with native views.
But that means, that you can still have some or your domain logic written in JS which you can use the same way in your Web App.
For example you have a Login Screen for iOS, but all the necessary stuff for your server calls, can go into a separate module e.g. api/auth.js
, which is shareable between web, ios, android, iot.. what ever.
Upvotes: 7
Reputation: 7382
It's good that you plan in advance. 100% matching between JS and Native won't be possible, but with careful planning, you could get to reuse a good deal.
You may want to take a look at React Native Web project that mirrors Native-specific components for Web (e.g. View, Image, Text, etc).
I suggest building a simple prototype in React JS and then in React Native so you get some understanding of the differences in the two ecosystems. Having a hands on experience will prove more beneficial than any writeup :)
Upvotes: 12