I have a react.js project were it has a reusable component, i’m planning to use the same component logic in react native with in the same source code by adding my react native ui layer and use the existing component logic.
Ex: listComponent.tsx
I have installed react-native into my react.js project and was able to implement my react native ui layer.
- Now Is it possible to have two UI layers in reusable component and switch them like if we run the component on web it should render the DOM element, if i run the same component from a react native project it should render the react native ui element.
- If i do react-native init inside the reactjs project source code, will be there any conflicts ?
Any suggestions are appreciated.
Thanks.
2
Answers
You should look into React-Native Web
You can create
index.ios.js
andindex.android.js
in your module. React native will rather use index.ios.js and index.android.js than the index.js and your react web project will ignore the .android.js and .ios.js