s-leg3ndz
s-leg3ndz

Reputation: 3528

Babel Optional Chaining

I would like add babel-plugin-transform-optional-chaining in my React Native project, but i've this error :

error: bundling failed: TypeError: Cannot read property 'loose' of undefined
    at _default (/home/user/project/node_modules/babel-plugin-transform-optional-chaining/lib/index.js:12:32)

My package.json :

"devDependencies": {
    "babel-jest": "21.2.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-optional-chaining": "^7.0.0-beta.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "21.2.1",
    "react-test-renderer": "16.0.0"
},

Anyone have already test this babel plugin in React Native project ?

Thank you !

Upvotes: 3

Views: 2815

Answers (2)

Rachomir
Rachomir

Reputation: 280

As far as I am concerned optional chaining is working only with babel v7, so you have to update from ver6 to ver7

Upvotes: 1

William Chou
William Chou

Reputation: 772

I also got the same error as you when trying to use optional chaining inside a create-react-app. From what I understand, you need to be using babel core 7, and the default for CRA is 6. Which version are you using currently?

Upvotes: 0

Related Questions