JavaScript Environment
When using React Native, you're going to be running your JavaScript code in two environments:
- In most cases, 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 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.
ES5
- Reserved Words:
promise.catch(function() { });
ES6
ES8
Stage 3
Specific
- JSX:
<View style={{color: 'red'}} />
- Flow:
function foo(x: ?number): string {};
- TypeScript:
function foo(x: number | undefined): string {};
- Babel Template: allows AST templating
Many standards functions are also available on all the supported JavaScript runtimes.
Browser
- console.{log, warn, error, info, trace, table, group, groupEnd}
- CommonJS require
- XMLHttpRequest, fetch
- {set, clear}{Timeout, Interval, Immediate}, {request, cancel}AnimationFrame
ES6
ES7
ES8
Specific