javascript – How to reuse reactjs component logic into react native

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.

Read more here: Source link