When using React Native, you're going to be running your JavaScript code in two environments:
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JavaScript engines in the future, so it's best to avoid relying on specifics of any runtime.
Syntax transformers make writing code more enjoyable by allowing you to use new JavaScript syntax without having to wait for support on all interpreters.
React Native ships with the Babel JavaScript compiler. Check Babel documentation on its supported transformations for more details.
A full list of React Native's enabled transformations can be found in metro-react-native-babel-preset.
Transformation | Code |
---|---|
ECMAScript 5 | |
Reserved Words | |
ECMAScript 2015 (ES6) | |
Arrow functions | |
Block scoping | |
Call spread | |
Classes | |
Computed Properties | |
Constants | |
Destructuring | |
for…of | |
Function Name | |
Literals | |
Modules | |
Object Concise Method | |
Object Short Notation | |
Parameters | |
Rest Params | |
Shorthand Properties | |
Sticky Regex | |
Template Literals | |
Unicode Regex | |
ECMAScript 2016 (ES7) | |
Exponentiation Operator | |
ECMAScript 2017 (ES8) | |
Async Functions | |
Function Trailing Comma | |
ECMAScript 2019 (ES10) | |
Optional Catch Binding | |
ECMAScript 2020 (ES11) | |
Dynamic Imports | |
Stage 1 Proposal | |
Export Default From | |
Stage 3 Proposal | |
Object Spread | |
Static Class Fields | |
Stage 4 Proposal | |
Nullish Coalescing Operator | |
Optional Chaining | |
Other Proposals | |
Class Properties | |
Miscellaneous | |
Babel Template | |
Flow | |
ESM to CJS | |
JSX | |
Object Assign | |
React Display Name | |
TypeScript |
Many standard functions are also available on all the supported JavaScript runtimes.
__DEV__
© 2022 Facebook Inc.
Licensed under the Creative Commons Attribution 4.0 International Public License.
https://reactnative.dev/docs/javascript-environment