diff --git a/docs/EmbeddedApp.md b/docs/EmbeddedApp.md index 77d431be6..71ae56d6c 100644 --- a/docs/EmbeddedApp.md +++ b/docs/EmbeddedApp.md @@ -4,7 +4,7 @@ title: Integration with Existing App layout: docs category: Guides permalink: docs/embedded-app.html -next: activityindicatorios +next: javascript-environment --- 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/). diff --git a/docs/JavaScriptEnvironment.md b/docs/JavaScriptEnvironment.md index 4d366d60a..a2bca7ea2 100644 --- a/docs/JavaScriptEnvironment.md +++ b/docs/JavaScriptEnvironment.md @@ -1,10 +1,18 @@ +--- +id: javascript-environment +title: JavaScript Environment +layout: docs +category: Guides +permalink: docs/javascript-environment.html +next: activityindicatorios +--- ## JavaScript Runtime When using React Native, you're going to be running your JavaScript code in two environments: * 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. -* 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/). +* 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/). 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. @@ -14,12 +22,14 @@ While both environments are very similar, you may end up hitting some inconsiste 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: ES5 + * Reserved Words: `promise.catch(function() { });` ES6 -* Arrow function: ` { this.setState({pressed: true}); }}` + +* Arrow function: ` this.setState({pressed: true})}` * Call spread: `Math.max(...array);` -* Class: `class MyComponent extends React.Component { render() { return ; } }` +* Class: `class C extends React.Component { render() { return ; } }` * Destructuring: `var {isActive, style} = this.props;` * Iteration: `for (var element of array) { }` * Computed Properties: `var key = 'abc'; var obj = {[key]: 10};` @@ -29,5 +39,6 @@ ES6 * Template: ``var who = 'world'; var str = `Hello ${who}`;`` ES7 + * Object Spread: `var extended = { ...obj, a: 10 };` * Function Trailing Comma: `function f(a, b, c,) { }` diff --git a/website/server/convert.js b/website/server/convert.js index cf7c8a806..8dfc4ce92 100644 --- a/website/server/convert.js +++ b/website/server/convert.js @@ -30,7 +30,7 @@ function splitHeader(content) { } function backtickify(str) { - var escaped = '`' + str.replace(/\\/g, '\\\\').replace(/`/g, '\\`') + '`'; + var escaped = '`' + str.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/{/g, '\\{') + '`'; // Replace require( with require\( so node-haste doesn't replace example // require calls in the docs return escaped.replace(/require\(/g, 'require\\(');