目前未为react-router-native启用对实验语法'classProperties'的支持吗?

时间:2019-04-21 05:47:46

标签: typescript react-native react-native-web react-router-native

我目前正在学习建立一个使用TypeScript的react-native-web的消息,并且在react-router-native抛出错误的地方报错:

  

当前未启用对实验语法“ classProperties”的支持。

检查了node_modules文件夹,并且metro-react-native-babel-preset添加了@babel/plugin-proposal-class-properties

尝试将plugins部分添加到babel中的package.json,但仍然出现错误:

"babel": {
    "plugins": [
      [
        "@babel/plugin-proposal-class-properties",
        {
          "loose": true
        }
      ]
    ],
    "presets": [
      "module:metro-react-native-babel-preset"
    ]
  }

这是我当前的设置

已安装package.json中的软件包:

{
"dependencies": {
    "react": "16.8.6",
    "react-dom": "16.8.6",
    "react-native": "0.59.3",
    "react-native-web": "0.11.2",
    "react-router": "5.0.0",
    "react-router-dom": "5.0.0",
    "react-router-native": "5.0.0",
    "react-scripts": "2.1.8"
  },
  "devDependencies": {
    "@types/jest": "24.0.11",
    "@types/react": "16.8.10",
    "@types/react-native": "0.57.42",
    "@types/react-router": "4.4.5",
    "@types/react-router-dom": "4.3.2",
    "@types/react-router-native": "4.2.4",
    "@types/react-test-renderer": "16.8.1",
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "prettier": "1.16.4",
    "react-art": "16.8.6",
    "react-test-renderer": "16.8.6",
    "ts-jest": "24.0.1",
    "tslint": "5.15.0",
    "tslint-config-prettier": "1.18.0",
    "typescript": "3.4.1"
  }
}

对于metro.config.js

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: true,
        inlineRequires: true
      }
    })
  }
};

0 个答案:

没有答案