2

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

LShi
  • 1,500
  • 16
  • 29

1 Answers1

2

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/

Jon Wood
  • 1,531
  • 14
  • 24