syntax 'nullishCoalescingOperator' isn't currently enabled

Viewed 12579

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 Answers

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

Related