syntax 'nullishCoalescingOperator' isn't currently enabled

为君一笑 提交于 2019-12-23 06:52:20

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/53944204/syntax-nullishcoalescingoperator-isnt-currently-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!