Skip to content

Commit

Permalink
Sync guides
Browse files Browse the repository at this point in the history
  • Loading branch information
charpeni committed Mar 20, 2019
1 parent 121b88b commit 0dc3729
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 10 deletions.
24 changes: 24 additions & 0 deletions website/versioned_docs/version-0.5/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,18 @@ react-native init AwesomeProject

This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo (or Create React Native App), or if you're adding iOS support to an existing React Native project (see [Platform Specific Code](platform-specific-code.md)). You can also use a third-party CLI to init your React Native app, such as [Ignite CLI](https://github.com/infinitered/ignite).

### [Optional] Using a specific version

If you want to start a new project with a specifc React Native version, you can use the `--version` argument:

```
react-native init AwesomeProject --version X.XX.X
```

```
react-native init AwesomeProject --version react-native@next
```

<block class="native mac windows linux android" />

## Creating a new application
Expand All @@ -454,6 +466,18 @@ react-native init AwesomeProject

This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Create React Native App, or if you're adding Android support to an existing React Native project (see [Platform Specific Code](platform-specific-code.md)). You can also use a third-party CLI to init your React Native app, such as [Ignite CLI](https://github.com/infinitered/ignite).

### [Optional] Using a specific version

If you want to start a new project with a specifc React Native version, you can use the `--version` argument:

```
react-native init AwesomeProject --version X.XX.X
```

```
react-native init AwesomeProject --version react-native@next
```

<block class="native mac windows linux android" />

## Preparing the Android device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Go to the root directory for your project and create a new `package.json` file w
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
"start": "yarn react-native start"
}
}
```
Expand Down
16 changes: 10 additions & 6 deletions website/versioned_docs/version-0.5/javascript-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,37 @@ ES5

ES6

* [Arrow functions](http://babeljs.io/docs/learn-es2015/#arrows): `<C onPress={() => this.setState({pressed: true})}`
* [Arrow functions](http://babeljs.io/docs/learn-es2015/#arrows): `<C onPress={() => this.setState({pressed: true})} />`
* [Block scoping](https://babeljs.io/docs/learn-es2015/#let-const): `let greeting = 'hi';`
* [Call spread](http://babeljs.io/docs/learn-es2015/#default-rest-spread): `Math.max(...array);`
* [Classes](http://babeljs.io/docs/learn-es2015/#classes): `class C extends React.Component { render() { return <View />; } }`
* [Constants](https://babeljs.io/docs/learn-es2015/#let-const): `const answer = 42;`
* [Destructuring](http://babeljs.io/docs/learn-es2015/#destructuring): `var {isActive, style} = this.props;`
* [for...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of): `for (var num of [1, 2, 3]) {}`
* [for...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of): `for (var num of [1, 2, 3]) {};`
* [Modules](http://babeljs.io/docs/learn-es2015/#modules): `import React, { Component } from 'react';`
* [Computed Properties](http://babeljs.io/docs/learn-es2015/#enhanced-object-literals): `var key = 'abc'; var obj = {[key]: 10};`
* [Object Concise Method](http://babeljs.io/docs/learn-es2015/#enhanced-object-literals): `var obj = { method() { return 10; } };`
* [Object Short Notation](http://babeljs.io/docs/learn-es2015/#enhanced-object-literals): `var name = 'vjeux'; var obj = { name };`
* [Rest Params](https://github.com/sebmarkbage/ecmascript-rest-spread): `function(type, ...args) { }`
* [Rest Params](https://github.com/sebmarkbage/ecmascript-rest-spread): `function(type, ...args) {};`
* [Template Literals](http://babeljs.io/docs/learn-es2015/#template-strings): `` var who = 'world'; var str = `Hello ${who}`; ``

ES8

* [Function Trailing Comma](https://github.com/jeffmo/es-trailing-function-commas): `function f(a, b, c,) { }`
* [Async Functions](https://github.com/tc39/ecmascript-asyncawait): `async function doStuffAsync() { const foo = await doOtherStuffAsync(); }`;
* [Function Trailing Comma](https://github.com/jeffmo/es-trailing-function-commas): `function f(a, b, c,) {};`
* [Async Functions](https://github.com/tc39/ecmascript-asyncawait): `async function doStuffAsync() { const foo = await doOtherStuffAsync(); };`

Stage 3

* [Object Spread](https://github.com/sebmarkbage/ecmascript-rest-spread): `var extended = { ...obj, a: 10 };`

Stage 1

* [Optional Chaining](https://github.com/tc39/proposal-optional-chaining): `var name = obj.user?.name;`

Specific

* [JSX](https://reactjs.org/docs/jsx-in-depth.html): `<View style={{color: 'red'}} />`
* [Flow](http://flowtype.org/): `function foo(x: ?number): string {}`
* [Flow](http://flowtype.org/): `function foo(x: ?number): string {};`

## Polyfills

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Then you just need a little bit of JavaScript to make this a usable React compon
import { requireNativeComponent } from 'react-native';
// requireNativeComponent automatically resolves 'RNTMap' to 'RNTMapManager'
module.exports = requireNativeComponent('RNTMap', null);
module.exports = requireNativeComponent('RNTMap');
// MyApp.js
Expand Down
6 changes: 5 additions & 1 deletion website/versioned_docs/version-0.5/native-modules-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This guide will use the [Toast](http://developer.android.com/reference/android/w

We start by creating a native module. A native module is a Java class that usually extends the `ReactContextBaseJavaModule` class and implements the functionality required by the JavaScript. Our goal here is to be able to write `ToastExample.show('Awesome', ToastExample.SHORT);` from JavaScript to display a short toast on the screen.

create a new Java Class named `ToastModule.java` inside `android/app/src/main/java/com/your-app-name/` folder with the content below:
Create a new Java Class named `ToastModule.java` inside `android/app/src/main/java/com/your-app-name/` folder with the content below:

```java
// ToastModule.java
Expand Down Expand Up @@ -156,6 +156,8 @@ protected List<ReactPackage> getPackages() {

To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of `NativeModules` each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.

Create a new JavaScript file named `ToastExample.js` with the content below:

```javascript
/**
* This exposes the native ToastExample module as a JS module. This has a
Expand All @@ -177,6 +179,8 @@ import ToastExample from './ToastExample';
ToastExample.show('Awesome', ToastExample.SHORT);
```

Please make sure this JavasScript file to be the same hierarchy as `ToastExample.js`.

## Beyond Toasts

### Callbacks
Expand Down
13 changes: 13 additions & 0 deletions website/versioned_docs/version-0.5/native-modules-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ console.log(CalendarManager.firstDayOfTheWeek);

Note that the constants are exported only at initialization time, so if you change `constantsToExport` values at runtime it won't affect the JavaScript environment.

### Implementing `+ requiresMainQueueSetup`

If you override `- constantsToExport` then you should also implement `+ requiresMainQueueSetup` to let React Native know if your module needs to be initialized on the main thread. Otherwise you will see a warning that in the future your module may be initialized on a background thread unless you explicitly opt out with `+ requiresMainQueueSetup`:

```objectivec
+ (BOOL)requiresMainQueueSetup
{
return YES; // only do this if your module initialization relies on calling UIKit!
}
```

If your module does not require access to UIKit, then you should respond to `+ requiresMainQueueSetup` with `NO`.

### Enum Constants

Enums that are defined via `NS_ENUM` cannot be used as method arguments without first extending RCTConvert.
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-0.5/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ project.ext.react = [

Finally, you can update "start" under "scripts" on your package.json to use the config:

`"start": "node node_modules/react-native/local-cli/cli.js start --config ../../../../packager/config.js",`
`"start": "yarn react-native start --config packager/config.js",`

Start your package server with `npm start`. Note that when the dev packager is automatically launched via xcode and `react-native run-android`, etc, it does not use `npm start`, so it won't use the config.

Expand Down

0 comments on commit 0dc3729

Please sign in to comment.