gpt4 book ai didi

react-native - 如果已启用,如何修复 "Support for the experimental syntax ' classProperties' 未启用”错误?

转载 作者:行者123 更新时间:2023-12-03 21:01:21 26 4
gpt4 key购买 nike

我从这个例子中为 Web、Android 和 iOS 构建了一个跨平台的 monorepo 应用程序 https://github.com/brunolemos/react-native-web-monorepo当我将 React Native Base 添加到我的项目时,我更改了我的 config-overrides.js根据本指南 https://docs.nativebase.io/docs/GetStarted.html网站

但在那之后我得到了SyntaxError: C:\Users\maksi\Desktop\ecmsk\node_modules\native-base\node_modules\react-native-vector-icons\lib\create-icon-set-from-fontawesome5.js: Support for the experimental syntax 'classProperties' isn't currently enabled错误。

我尝试添加 loose选项 @babel/plugin-proposal-class-properties插件,但这没有用。我也尝试添加 plugins到我的 package.json这也不起作用。

package.json

{
"name": "web",
"version": "0.0.1",
"private": true,
"dependencies": {
"@types/history": "^4.7.2",
"@types/js-cookie": "^2.2.2",
"@types/react": "^16.8.23",
"@types/react-redux": "^7.1.1",
"@types/redux-api-middleware": "^3.0.1",
"connected-react-router": "^6.5.2",
"history": "^4.9.0",
"js-cookie": "^2.2.0",
"native-base": "^2.13.4",
"react": "16.8.4",
"react-art": "^16.8.6",
"react-dom": "16.8.4",
"react-native-elements": "^1.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "0.10.0",
"react-redux": "^7.1.0",
"react-router": "^5.0.1",
"react-scripts": "2.1.8",
"redux": "^4.0.4",
"redux-api-middleware": "^3.0.1"
},
"scripts": {
"compile": "tsc -b",
"prestart": "npm run compile",
"start": "concurrently \"npm run compile -- -w\" \"npm run _start\"",
"_start": "react-app-rewired start",
"prebuild": "npm run compile",
"build": "react-app-rewired build",
"pretest": "npm run compile",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"babel-plugin-react-native-web": "^0.11.5",
"concurrently": "*",
"customize-cra": "^0.4.1",
"react-app-rewired": "^2.1.3",
"typescript": "*"
}
}


config-overrides.js
const path = require('path');
const {
override,
addWebpackAlias,
babelInclude,
addBabelPlugins
} = require('customize-cra');

module.exports = override(
addWebpackAlias({
"react-native/Libraries/Renderer/shims/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
"react-native": "react-native-web"
}),
babelInclude([
path.resolve('src'),
path.resolve('../components/src'),
path.resolve('../../node_modules/native-base-shoutem-theme'),
path.resolve('../../node_modules/react-navigation'),
path.resolve('../../node_modules/react-native-easy-grid'),
path.resolve('../../node_modules/react-native-drawer'),
path.resolve('../../node_modules/react-native-safe-area-view'),
path.resolve('../../node_modules/react-native-vector-icons'),
path.resolve('../../node_modules/react-native-keyboard-aware-scroll-view'),
path.resolve('../../node_modules/react-native-web'),
path.resolve('../../node_modules/react-native-tab-view'),
path.resolve('../../node_modules/static-container'),
]),
addBabelPlugins(
"@babel/plugin-proposal-class-properties"
),
);

最佳答案

问题可能是包含的路径。在我的情况下,我是这样的:

babelInclude([
path.resolve('node_modules/react-native-typing-animation'),
path.resolve('src')
])
路径相对于 config.overrides 文件。

关于react-native - 如果已启用,如何修复 "Support for the experimental syntax ' classProperties' 未启用”错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57342220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com