Summary: Though not currently in use in the RN code, when `react-native-windows` tried to integrate changes up to 7/28/23 (see PR https://github.com/microsoft/react-native-windows/pull/11970) there happened to be a `??=` operator in the `virtualized-lists` package (see [diff here](https://github.com/facebook/react-native/compare/ccc50ddd2...c168a4f88#diff-abeff2daf5909e54a23562e43569de1d5b8db1d7170119eed485b618cdf04ec7R322)). (The offending line was removed in a later commit). The default RNW engine is still Chakra and it couldn't handle the syntax. It looks like the `babel/plugin-proposal-nullish-coalescing-operator` plugin only handles `??`, so to handle `??=` I've added `babel/plugin-proposal-logical-assignment-operators`, which also happens to handle the logical assignment operators `||=` and `&&=`. Closes https://github.com/facebook/react-native/issues/31704 ## Changelog: [GENERAL] [FIXED] - Add detection of logical assignment operators to `react-native-babel-preset` Pull Request resolved: https://github.com/facebook/react-native/pull/39186 Test Plan: We started using these plugins in RNW's babel config to resolve the issue in our integrate PR. Reviewed By: motiz88 Differential Revision: D50936554 Pulled By: rozele fbshipit-source-id: 0a924b6085524d8c9551a158b91195b1f7448c19
@react-native/babel-preset
Babel presets for React Native applications. React Native itself uses this Babel preset by default when transforming your app's source code.
If you wish to use a custom Babel configuration by writing a babel.config.js file in your project's root directory, you must specify all the plugins necessary to transform your code. React Native does not apply its default Babel configuration in this case. So, to make your life easier, you can use this preset to get the default configuration and then specify more plugins that run before it.
Usage
As mentioned above, you only need to use this preset if you are writing a custom babel.config.js file.
Installation
Install @react-native/babel-preset in your app:
with npm:
npm i @react-native/babel-preset --save-dev
or with yarn:
yarn add -D @react-native/babel-preset
Configuring Babel
Then, create a file called babel.config.js in your project's root directory. The existence of this babel.config.js file will tell React Native to use your custom Babel configuration instead of its own. Then load this preset:
{
"presets": ["module:@react-native/babel-preset"]
}
You can further customize your Babel configuration by specifying plugins and other options. See Babel's babel.config.js documentation to learn more.
Help and Support
If you get stuck configuring Babel, please ask a question on Stack Overflow or find a consultant for help. If you discover a bug, please open up an issue.