目前尚不支持对实验语法“ classProperties”的支持

时间:2018-11-27 12:39:47

标签: react-native

我看到了各种各样的答案和github问题,并一一尝试,但仍然无法解决。我正在处理某人过去的工作;现在尝试复制并运行它,但是出错。我想库react-native-router-flux是引发错误的地方:

./ node_modules / react-native-router-flux / src / Router.js 语法错误:D:\ kokob \ node_modules \ react-native-router-flux \ src \ Router.js:目前未启用对实验语法'classProperties'的支持

在继续在各个地方用反应导航替换它之前,我想知道我是否可以解决问题?

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {

    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-native-router-flux": "^4.0.6",
    "react-scripts": "2.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ],
    "plugins": [
      [
        "@babel/plugin-proposal-class-properties",
        {
          "loose": true
        }
      ]
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-react": "^7.0.0"
  }
}

babel.config.js

module.exports = function() {
  const presets = ["@babel/preset-env", "@babel/preset-react"];
  const plugins = ["@babel/plugin-proposal-class-properties"];

  return {
    presets,
    plugins
  };
};

.babelrc或先前的babel.config.js

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": [["@babel/plugin-proposal-class-properties"]]
}

0 个答案:

没有答案