我按照这个教程将
react-native-web
添加到react-native
项目中,但是在将react-native-vector-icons
添加到项目时出现了错误。./node_modules/react-native-vector-icons/lib/create-icon-set.js
SyntaxError: /home/hamidreza/Desktop/myApp/node_modules/react-native-vector-icons/lib/create-icon-set.js: Support for the experimental syntax 'classProperties' isn't currently enabled (43:22):
41 |
42 | class Icon extends PureComponent {
> 43 | static propTypes = {
| ^
44 | allowFontScaling: PropTypes.bool,
45 | name: IconNamePropType,
46 | size: PropTypes.number,
我也更改了我的babel.config.js
文件如下:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'@babel/plugin-proposal-class-properties',
{
loose: true,
},
],
],
};
或者
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'@babel/plugin-proposal-class-properties'
],
};
但问题仍然存在。
我应该怎么办?
web/webpack.config.js
更改为答案中的内容。 - BeHappy