LShi
LShi

Reputation: 1502

Using @babel/plugin-proposal-nullish-coalescing-operator with "babel-preset-expo"

The project was created with create-react-native-app.

When I use code like const a = 2 ?? 3, there will be an error complaining "Cannot read property 'loose' of undefined".

I tried adding the @babel/plugin-proposal-nullish-coalescing-operator plugin, but there's a build error.

.babelrc

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  },
  "plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"]
}

enter image description here

Upvotes: 2

Views: 5564

Answers (1)

Jon Wood
Jon Wood

Reputation: 1731

This might be a problem with your babel version:

Make sure that you've installed all the correct babel 7 dependencies, e.g.:

@babel/core instead of babel-core

@babel/cli instead of babel-cli

@babel/preset-env instead of babel-preset-env

https://www.menubar.io/cannot-read-property-loose-of-undefined/

Upvotes: 2

Related Questions