skip to Main Content

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.

  1. 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.
  2. If i do react-native init inside the reactjs project source code, will be there any conflicts ?

Any suggestions are appreciated.
Thanks.

2

Answers


  1. You should look into React-Native Web

    Login or Signup to reply.
  2. You can create index.ios.js and index.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

    1. Create index.ios.js and index.android.js in your module
    2. index.ios.js and index.android.js can import MyMobileView.tsx
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search