23

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.

Mahgolsadat Fathi
  • 3,107
  • 4
  • 16
  • 34
  • Javascript doesn't have the `Nullish Coalescing` operator right now, the proposal for `Nullish Coalescing` proposal is at stage-1 in TC39. – Mostafiz Rahman Dec 27 '18 at 11:36

1 Answers1

32

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

Mahgolsadat Fathi
  • 3,107
  • 4
  • 16
  • 34