7

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?

1

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

I want to merge so both native and web work not only native.
as you can see in scripts "start" in the web is different than native
Than first problem you will find are different versions of react: "react": "^15.6.1" and "16.0.0-alpha.12", you can try run them both with 16-beta, seams React Native for Web supports it now github.com/necolas/react-native-web/issues/364 I haven't tried that. In my project I have different folders "app" (containing native app) and "web", both having different node_modules and share src files which are in "app" folder
About scripts, like "start", you can rename web one to "start-web"
There will be only few of them that are just for web, like "react-dom" and react native will not import those at all, they will be just installed in node_modules, but not used by react native, they will be used by react native for web. So this should not increase size of mobile builds.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.