当前未启用语法“nullishCoalescingOperator" [英] syntax 'nullishCoalescingOperator' isn't currently enabled

查看:173
本文介绍了当前未启用语法“nullishCoalescingOperator"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 ios-simulator 上构建我的应用程序时,它说:

捆绑失败:SyntaxError:/Users/MyName/MyApp/node_modules/react-native/node_modules/react-native/Libraries/Components/Switch/Switch.js:支持实验语法nullishCoalescingOperator当前未启用 (167:52):

<代码> 165 |{...道具}166 |{...platformProps}>167 |AccessibilityRole={props.accessibilityRole ??'按钮'}|^168 |onChange={this._handleChange}169 |onResponderTerminationRequest={returnsFalse}170 |onStartShouldSetResponder={returnsTrue}

将@babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) 添加到 Babel 配置的插件"部分以启用转换.>

我按照它说的做了,但它没有帮助...任何帮助将不胜感激.

解决方案

我认为它通过将我的 .babelrc 更改为

来解决

<代码>{预设":[模块:metro-react-native-babel-preset"]}

这个变化是因为升级我的 react-native 版本

when I tried to build my app on ios-simulator it says :

bundling failed: SyntaxError: /Users/MyName/MyApp/node_modules/react-native/node_modules/react-native/Libraries/Components/Switch/Switch.js: Support for the experimental syntax nullishCoalescingOperator isn't currently enabled (167:52):

 165 |         {...props}
  166 |         {...platformProps}
> 167 |         accessibilityRole={props.accessibilityRole ?? 'button'}
      |                                                    ^
  168 |         onChange={this._handleChange}
  169 |         onResponderTerminationRequest={returnsFalse}
  170 |         onStartShouldSetResponder={returnsTrue}

Add @babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) to the 'plugins' section of your Babel config to enable transformation.

I did what it says, but it just didn't help... Any help will be appreciated.

解决方案

I think it resolved by changing my .babelrc to

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

this change is caused by upgrading my react-native version

这篇关于当前未启用语法“nullishCoalescingOperator"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆