React Native错误:您当前正在使用Redux在NODE_ENV ==='production'之外使用缩小代码

时间:2018-12-22 16:48:49

标签: node.js reactjs react-native

我一直在寻找并尝试摆脱此错误而没有成功。我阅读了webpack的整个文档,并尝试正确实现它,但是似乎不起作用。我使用expo,也许expo的条目有问题,但我不知道。

这是我的代码:

webpack.config.js

 var path = require('path');

module.exports = {
  mode: 'production',
  entry: "./App.js",
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
};

App.js

import * as React from "react";
import { Provider } from "react-redux";
import { createStore  } from "redux";
import { reducers } from "./reducers";

import { Drawer } from "./Navigation";
import LibraryReducer from "./reducers/LibraryReducer";

export default class App extends React.Component {
  render() {
    const store = createStore(LibraryReducer)
    return (
      <Provider store={store}>
        <Drawer />
      </Provider>

    );
  }
}

package.json

{
  "name": "empty-project-template",
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "start": "webpack",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "build": "webpack --config webpack.config.js"
  },
  "dependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-transform-react-jsx-source": "^7.0.0",
    "@expo/vector-icons": "^8.0.0",
    "babel-preset-expo": "^5.0.0",
    "create-webpack-config": "^0.2.1",
    "db": "^1.1.1",
    "expo": "^31.0.0",
    "expo-asset": "^1.0.2",
    "expo-constants": "^1.1.0",
    "expo-core": "^1.2.0",
    "expo-file-system": "^1.1.0",
    "expo-font": "^1.1.0",
    "expo-react-native-adapter": "^1.0.2",
    "loose-envify": "^1.4.0",
    "metro-react-native-babel-preset": "^0.50.0",
    "native-base": "^2.8.0",
    "pirates": "^4.0.0",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
    "react-native-calendars": "^1.20.0",
    "react-native-dialog": "^5.3.0",
    "react-native-elements": "^0.19.1",
    "react-native-haptic-feedback": "^1.2.0",
    "react-native-simple-dialogs": "^0.4.1",
    "react-native-swipeout": "^2.3.6",
    "react-native-vector-icons": "^5.0.0",
    "react-native-view-overflow": "^0.0.3",
    "react-navigation": "^2.12.1",
    "react-redux": "^6.0.0",
    "redux": "^4.0.1",
    "watchman": "^1.0.0"
  },
  "devDependencies": {
    "webpack": "^4.27.1",
    "webpack-cli": "^3.1.2"
  }
}

.babelrc

{
  "presets": ["module:metro-react-native-babel-preset"]
}

欢迎提出任何想法。

1 个答案:

答案 0 :(得分:0)

您可能早就解决了这个问题,但是我遇到了同样的问题,并通过在.expo/settings.json中将minify设置更改为此行来解决了此问题:

"minify": false

先前已将其设置为true