How to reuse React JS component in React Native

I am new to React JS . I'm trying to create a web application that should also work on mobile devices (Android and IOS), so I thought about using React JS for a web application and created several components. therefore, you can use the React JS component in React native .

+7
javascript reactjs react-native
source share
2 answers

Good thing you plan ahead. A 100% match between JS and Native will not be possible, but with careful planning you can reuse a lot.

You might want to take a look at the React Native Web project , which displays individual-specific components for the Web (e.g., View, Image, Text, etc.).

I suggest creating a simple prototype in React JS and then in React Native so that you understand the differences in the two ecosystems. Having experience will be more useful than any entry :)

+6
source share

ReactNative is a set of real native components, such as View , TextInput TouchableHighlight and more . It is also a platform that allows you to run javascript code to control them.

There is no WebView in Cordoba, what you get is a native application with its own views.

But that means that you can still have some or your domain logic written in JS that you can use in the same way in your web application.

For example, you have a login screen for iOS, but all the necessary materials for calling your server can go to a separate module, for example. api/auth.js , which is shared between the network, ios, android, iot .. what ever.

+5
source share

All Articles