Skip to main content
Join us for React Conf on Oct 7-8. Learn more.
This is documentation for React Native 0.79, which is no longer in active development.
For up-to-date documentation, see the latest version (0.81).
Version: 0.79

JavaScript Environment

JavaScript Runtime​

When using React Native, you're going to be running your JavaScript code in up to three environments:

  • In most cases, React Native will use Hermes, an open-source JavaScript engine optimized for React Native.
  • If Hermes is disabled, React Native will use JavaScriptCore, the JavaScript engine that powers Safari. Note that on iOS, JavaScriptCore does not use JIT due to the absence of writable executable memory in iOS apps.
  • When using Chrome debugging, all JavaScript code runs within Chrome itself, communicating with native code via WebSockets. Chrome uses V8 as its JavaScript engine.

While these environments are very similar, you may end up hitting some inconsistencies. It is best to avoid relying on specifics of any runtime.

JavaScript Syntax Transformers​

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 @react-native/babel-preset.

TransformationCode
ECMAScript 5
Reserved Words
promise.catch(function(){...});
ECMAScript 2015 (ES6)
Arrow functions
<ConPress={()=>this.setState({pressed:true})}/>
Block scoping
let greeting ='hi';
Call spread
Math.max(...array);
Classes
classCextendsReact.Component{render(){return<View/>;}}
Computed Properties
const key ='abc';const obj ={[key]:10};
Constants
const answer =42;
Destructuring
const{isActive, style}=this.props;
for...of
for(var num of[1,2,3]){...};
Function Name
letnumber= x => x;
Literals
const b =0b11;const o =0o7;const u ='Hello\u{000A}\u{0009}!';
Modules
importReact,{Component}from'react';
Object Concise Method
const obj ={method(){return10;}};
Object Short Notation
const name ='vjeux';const obj ={name};
Parameters
functiontest(x ='hello',{a, b},...args){}
Rest Params
function(type,...args){};
Shorthand Properties
const o ={a, b, c};
Sticky Regex
const a =/o+/y;
Template Literals
const who ='world';const str =`Hello ${who}`;
Unicode Regex
conststring='fooπŸ’©bar';const match =string.match(/foo(.)bar/u);
ECMAScript 2016 (ES7)
Exponentiation Operator
let x =10**2;
ECMAScript 2017 (ES8)
Async Functions
asyncfunctiondoStuffAsync(){const foo =awaitdoOtherStuffAsync();};
Function Trailing Comma
functionf(a, b, c,){};
ECMAScript 2018 (ES9)
Object Spread
const extended ={...obj, a:10};
ECMAScript 2019 (ES10)
Optional Catch Binding
try{throw0;}catch{doSomethingWhichDoesNotCareAboutTheValueThrown();}
ECMAScript 2020 (ES11)
Dynamic Imports
constpackage=awaitimport('package');package.function()
Nullish Coalescing Operator
const foo = object.foo??'default';
Optional Chaining
const name = obj.user?.name;
ECMAScript 2022 (ES13)
Class Fields
classBork{static a ='foo';static b; x ='bar'; y;}
Stage 1 Proposal
Export Default From
export v from'mod';
Miscellaneous
Babel Template
template(`const %%importName%% = require(%%source%%);`);
Flow
functionfoo(x:?number):string{};
ESM to CJS
exportdefault42;
JSX
<Viewstyle={{color:'red'}}/>
Object Assign
Object.assign(a, b);
React Display Name
const bar =createReactClass({});
TypeScript
functionfoo(x:{hello:true, target:'react native!'}):string{};

Polyfills​

Many standard functions are also available on all the supported JavaScript runtimes.

Browser​

ECMAScript 2015 (ES6)​

ECMAScript 2016 (ES7)​

ECMAScript 2017 (ES8)​

Specific​

  • __DEV__

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /