Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge react app with react native app

I want to put React app files in the React Native app.

I used React Native Web to support React Native components in the React app.

Last step I want to put all files from React App folder to React Native App folder.

the difference is in Package.json

React Package.json :

{
  "name": "appname",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-scripts": "1.0.10"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

React Native Package.json:

{
    "name": "appname",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "react": "16.0.0-alpha.12",
        "react-native": "0.47.1",
        "react-native-windows": "0.47.0-rc.5"
    },
    "devDependencies": {
        "babel-jest": "20.0.3",
        "babel-preset-react-native": "2.1.0",
        "jest": "20.0.4",
        "react-test-renderer": "16.0.0-alpha.12",
        "rnpm-plugin-windows": "^0.2.7"
    },
    "jest": {
        "preset": "react-native"
    }
}

So is it possible I can merge the two packages together?

like image 573
amorenew Avatar asked Aug 08 '17 06:08

amorenew


People also ask

Can I combine React and React Native?

As long as we are building our application purely within the framework, we can drive our app with properties and callbacks. But, when we mix React Native and native components, we need some specific, cross-language mechanisms that would allow us to pass information between them.

How do I transfer one React app to another?

npm install app1 (assuming app1 is your first app name). After it is installed, you can see your app1 files inside the node_modules/App1/ . Now your can import the files or components you want and use it in other apps. Hope this helps.

Can we combine native iOS or Android code in React Native?

Yes, we can combine Android or iOS code in react native. React Native helps to smoothly combines the components written in Java, Objective-C or Swift.


1 Answers

For your native app you can use package.json from React Native, no need to merge. You don't need "react-dom" and similar libs in native app. If your components are all from React Native for Web, there will be no problem running them on native.

like image 124
zarcode Avatar answered Oct 15 '22 10:10

zarcode