Skip to content

Commit 1c7f39e

Browse files
committed
Add JavaScript Environment in the docs and fix a few things
1 parent e0a0bb1 commit 1c7f39e

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

docs/EmbeddedApp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Integration with Existing App
44
layout: docs
55
category: Guides
66
permalink: docs/embedded-app.html
7-
next: activityindicatorios
7+
next: javascript-environment
88
---
99

1010
Since React makes no assumptions about the rest of your technology stack – it’s commonly noted as simply the `V` in `MVC` – it’s easily embeddable within an existing non-React Native app. In fact, it integrates with other best practice community tools like [CocoaPods](http://cocoapods.org/).

docs/JavaScriptEnvironment.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
---
2+
id: javascript-environment
3+
title: JavaScript Environment
4+
layout: docs
5+
category: Guides
6+
permalink: docs/javascript-environment.html
7+
next: activityindicatorios
8+
---
19

210
## JavaScript Runtime
311

412
When using React Native, you're going to be running your JavaScript code in two environments:
513

614
* In the simulator and on the phone: [JavaScriptCore](http://trac.webkit.org/wiki/JavaScriptCore) which is the JavaScript engine that powers Safari and web views. Due to the absence of writable executable memory in iOS apps, it doesn't run with JIT.
7-
* When using Chrome debugging, it runs all the JavaScript code within Chrome itself and communicate with the obj-c via WebSocket. So you are using [V8](https://code.google.com/p/v8/).
15+
* When using Chrome debugging, it runs all the JavaScript code within Chrome itself and communicate with Objective-C via WebSocket. So you are using [V8](https://code.google.com/p/v8/).
816

917
While both environments are very similar, you may end up hitting some inconsistencies. We're likely going to experiment with other JS engines in the future, so it's best to avoid relying on specifics of any runtime.
1018

@@ -14,12 +22,14 @@ While both environments are very similar, you may end up hitting some inconsiste
1422
React Native ships with many JavaScript transforms to make writing code more enjoyable. If you are curious, you can see the [implementation of all those transformations](https://github.com/facebook/jstransform/tree/master/visitors). Here's the full list:
1523

1624
ES5
25+
1726
* Reserved Words: `promise.catch(function() { });`
1827

1928
ES6
20-
* Arrow function: `<TouchableHighlight onPress={() => { this.setState({pressed: true}); }}`
29+
30+
* Arrow function: `<C onPress={() => this.setState({pressed: true})}`
2131
* Call spread: `Math.max(...array);`
22-
* Class: `class MyComponent extends React.Component { render() { return <View />; } }`
32+
* Class: `class C extends React.Component { render() { return <View />; } }`
2333
* Destructuring: `var {isActive, style} = this.props;`
2434
* Iteration: `for (var element of array) { }`
2535
* Computed Properties: `var key = 'abc'; var obj = {[key]: 10};`
@@ -29,5 +39,6 @@ ES6
2939
* Template: ``var who = 'world'; var str = `Hello ${who}`;``
3040

3141
ES7
42+
3243
* Object Spread: `var extended = { ...obj, a: 10 };`
3344
* Function Trailing Comma: `function f(a, b, c,) { }`

website/server/convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function splitHeader(content) {
3030
}
3131

3232
function backtickify(str) {
33-
var escaped = '`' + str.replace(/\\/g, '\\\\').replace(/`/g, '\\`') + '`';
33+
var escaped = '`' + str.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/{/g, '\\{') + '`';
3434
// Replace require( with require\( so node-haste doesn't replace example
3535
// require calls in the docs
3636
return escaped.replace(/require\(/g, 'require\\(');

0 commit comments

Comments
 (0)