Bomber
Bomber

Reputation: 10957

React native ios error, 'optionalChaining' isn't currently enabled

Trying to build my react native app I get this error:

error: bundling failed: SyntaxError: /xxxxr/node_modules/react-native/node_modules/react-native/Libraries/Components/Switch/Switch.js: Support for the experimental syntax 'optionalChaining' isn't currently enabled (103:41):

I have added:

{
  "presets": ["react-native"],
  "plugins": ["@babel/plugin-proposal-optional-chaining"]
}

To my .babelrc but I still get the error. How can I build my project?

Upvotes: 0

Views: 2428

Answers (1)

Sandy.....
Sandy.....

Reputation: 2870

Try installing plugin-proposal-optional-chaining plugin as follows:

npm install --save-dev @babel/plugin-proposal-optional-chaining

Try adding below code to your .babelrc:

{
  "plugins": [
    "@babel/plugin-proposal-optional-chaining"
  ],
  "presets": [
    "react-native"
  ]
}

Hope it will help you.

Upvotes: 1

Related Questions