DEV Community

Discussion on: Share Code Between React Native and React.js

Collapse
 
kathirpandian1993 profile image
kathirpandian1993

is there a way to reuse the reactjs code in react-native or react-native code in reactjs

Collapse
 
kpiteng profile image
kpiteng

We can use only JS Code which are not dependent on any of either React Native/ React.js library. Example - If you want to share code which uses React Native Async Storage then that will create issue in React.js - as React.js don't have that library. But yes whatever common code / pure JS code we can share across both apps.

Collapse
 
kmsayem12 profile image
Saifullah SaYem

I think you can share react native UI components for web, But you need to use react-native-web package.
example here necolas.github.io/react-native-web/

Collapse
 
aliakbarazizi profile image
Ali Akbar Azizi • Edited

You can't share UI elements, but you can create custom hook and share that logic between component