Skip to content

Commit

Permalink
Prettify code (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun authored and hramos committed May 8, 2018
1 parent 8fa4464 commit 85df282
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 78 deletions.
10 changes: 5 additions & 5 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ Small pull requests are much easier to review and more likely to get merged. Mak

Please make sure the following is done when submitting a pull request:

1. Fork [the repository](https://github.com/facebook/react-native) and create your branch from `master`.
2. Add the copyright notice to the top of any new files you've added.
3. Describe your [**test plan**](contributing.html#test-plan) in your pull request description. Make sure to [test your changes](testing.html)!
4. Make sure your code lints (`npm run lint`).
5. If you haven't already, [sign the CLA](https://code.facebook.com/cla).
1. Fork [the repository](https://github.com/facebook/react-native) and create your branch from `master`.
2. Add the copyright notice to the top of any new files you've added.
3. Describe your [**test plan**](contributing.html#test-plan) in your pull request description. Make sure to [test your changes](testing.html)!
4. Make sure your code lints (`npm run lint`).
5. If you haven't already, [sign the CLA](https://code.facebook.com/cla).

All pull requests should be opened against the `master` branch. After opening your pull request, ensure [**all tests pass**](contributing.html#contrinuous-integration-tests) on Circle CI. If a test fails and you believe it is unrelated to your change, leave a comment on the pull request explaining why.

Expand Down
2 changes: 1 addition & 1 deletion docs/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ Does not work for static image resources.
| ------- | -------- | -------- | ---------------------------------------------------------------------------------------------------- |
| uri | string | Yes | The location of the image. |
| success | function | Yes | The function that will be called if the image was successfully found and width and height retrieved. |
| failure | function | No | The function that will be called if there was an error, such as failing to retrieve the image. |
| failure | function | No | The function that will be called if there was an error, such as failing to retrieve the image. |

---

Expand Down
6 changes: 3 additions & 3 deletions docs/keyboardavoidingview.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ The style of the content container(View) when behavior is 'position'.

Enabled or disabled KeyboardAvoidingView.

| Type | Required |
| ---------- | -------- |
| boolean | Yes |
| Type | Required |
| ------- | -------- |
| boolean | Yes |

## Methods

Expand Down
6 changes: 3 additions & 3 deletions docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ handleOnPress() {

As mentioned above, `Navigator` animations are controlled by the JavaScript thread. Imagine the "push from right" scene transition: each frame, the new scene is moved from the right to left, starting offscreen (let's say at an x-offset of 320) and ultimately settling when the scene sits at an x-offset of

0. Each frame during this transition, the JavaScript thread needs to send a new x-offset to the main thread. If the JavaScript thread is locked up, it cannot do this and so no update occurs on that frame and the animation stutters.
0. Each frame during this transition, the JavaScript thread needs to send a new x-offset to the main thread. If the JavaScript thread is locked up, it cannot do this and so no update occurs on that frame and the animation stutters.

One solution to this is to allow for JavaScript-based animations to be offloaded to the main thread. If we were to do the same thing as in the above example with this approach, we might calculate a list of all x-offsets for the new scene when we are starting the transition and send them to the main thread to execute in an optimized way. Now that the JavaScript thread is freed of this responsibility, it's not a big deal if it drops a few frames while rendering the scene -- you probably won't even notice because you will be too distracted by the pretty transition.

Expand Down Expand Up @@ -225,8 +225,8 @@ This doesn't seem right. Why is it being called so often? Are they actually diff

If you identified a native UI problem, there are usually two scenarios:

1. the UI you're trying to draw each frame involves too much work on the GPU, or
2. You're constructing new UI during the animation/interaction (e.g. loading in new content during a scroll).
1. the UI you're trying to draw each frame involves too much work on the GPU, or
2. You're constructing new UI during the animation/interaction (e.g. loading in new content during a scroll).

##### Too much GPU work

Expand Down
14 changes: 7 additions & 7 deletions docs/running-on-device.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ Open a terminal and type `/sbin/ifconfig` to find your machine's IP address.

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

1. Make sure your laptop and your phone are on the **same** Wi-Fi network.
2. Open your React Native app on your device.
3. You'll see a [red screen with an error](debugging.md#in-app-errors-and-warnings). This is OK. The following steps will fix that.
4. Open the in-app [Developer menu](debugging.md#accessing-the-in-app-developer-menu).
5. Go to **Dev Settings****Debug server host & port for device**.
6. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081).
7. Go back to the **Developer menu** and select **Reload JS**.
1. Make sure your laptop and your phone are on the **same** Wi-Fi network.
2. Open your React Native app on your device.
3. You'll see a [red screen with an error](debugging.md#in-app-errors-and-warnings). This is OK. The following steps will fix that.
4. Open the in-app [Developer menu](debugging.md#accessing-the-in-app-developer-menu).
5. Go to **Dev Settings****Debug server host & port for device**.
6. Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081).
7. Go back to the **Developer menu** and select **Reload JS**.

You can now enable Live reloading from the [Developer menu](debugging.md#accessing-the-in-app-developer-menu). Your app will reload whenever your JavaScript code has changed.

Expand Down
23 changes: 13 additions & 10 deletions docs/sectionlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ If you don't need section support and want a simpler interface, use [`<FlatList>
Simple Examples:

```javascript
// Example 1 (Homogeneous Rendering)
<SectionList
renderItem={({ item, index, section }) => <Text key={index}>{item}</Text>}
renderSectionHeader={({ section: { title } }) => <Text style={{ fontWeight: 'bold' }}>{title}</Text>}
sections={[
{ title: 'Title1', data: ['item1', 'item2'] },
{ title: 'Title2', data: ['item3', 'item4'] },
{ title: 'Title3', data: ['item5', 'item6'] },
]}
keyExtractor={(item, index) => item + index} />
// Example 1 (Homogeneous Rendering)
<SectionList
renderItem={({item, index, section}) => <Text key={index}>{item}</Text>}
renderSectionHeader={({section: {title}}) => (
<Text style={{fontWeight: 'bold'}}>{title}</Text>
)}
sections={[
{title: 'Title1', data: ['item1', 'item2']},
{title: 'Title2', data: ['item3', 'item4']},
{title: 'Title3', data: ['item5', 'item6']},
]}
keyExtractor={(item, index) => item + index}
/>
```

```javascript
Expand Down
11 changes: 1 addition & 10 deletions docs/signed-apk-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ This command prompts you for passwords for the keystore and key, and to provide

The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app, so remember to take note of the alias.

On Mac if you not sure where is your jdk bin folder is then perform the following command to find it,
`$ /usr/libexec/java_home`
it will output the directroy of jdk which looks like this,
`/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home`
then navigate to that directory by the following command,
`$ cd /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/`
Now you can perform the keytool command with sudo permission as shown below,
`$ sudo keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000`

_Note: Remember to keep your keystore file private and never commit it to version control._
On Mac if you not sure where is your jdk bin folder is then perform the following command to find it, `$ /usr/libexec/java_home` it will output the directroy of jdk which looks like this, `/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home` then navigate to that directory by the following command, `$ cd /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/` Now you can perform the keytool command with sudo permission as shown below, `$ sudo keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000` _Note: Remember to keep your keystore file private and never commit it to version control._

### Setting up gradle variables

Expand Down
4 changes: 2 additions & 2 deletions docs/textinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ Possible values for `textContentType` are:
* `username`
* `password`

| Type | Required | Platform |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
| Type | Required | Platform |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
| enum('none', 'URL', 'addressCity', 'addressCityAndState', 'addressState', 'countryName', 'creditCardNumber', 'emailAddress', 'familyName', 'fullStreetAddress', 'givenName', 'jobTitle', 'location', 'middleName', 'name', 'namePrefix', 'nameSuffix', 'nickname', 'organizationName', 'postalCode', 'streetAddressLine1', 'streetAddressLine2', 'sublocality', 'telephoneNumber', 'username', 'password') | No | iOS |

---
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class HelloWorldApp extends Component {
<View>
<Text>Hello world!</Text>
</View>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/using-a-scrollview.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class IScrolledDownAndWhatHappenedNextShockedMe extends Component
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Text style={{fontSize:96}}>What's the best</Text>
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
Expand All @@ -44,7 +44,7 @@ export default class IScrolledDownAndWhatHappenedNextShockedMe extends Component
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Image source={{uri: "http://facebook.github.io/react-native/img/favicon.png", width: 64, height: 64}} />
<Text style={{fontSize:80}}>React Native</Text>
</ScrollView>
);
Expand Down
14 changes: 7 additions & 7 deletions docs/viewpagerandroid.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ A helper function to scroll to a specific page in the ViewPager. The transition

* position - index of page that will be selected

| Type | Required |
| -------- | -------- |
| Number | Yes |
| Type | Required |
| ------ | -------- |
| Number | Yes |

---

### `setPageWithoutAnimation`

A helper function to scroll to a specific page in the ViewPager. The transition between pages will *not* be animated.
A helper function to scroll to a specific page in the ViewPager. The transition between pages will _not_ be animated.

* position - index of page that will be selected

| Type | Required |
| -------- | -------- |
| Number | Yes |
| Type | Required |
| ------ | -------- |
| Number | Yes |

## Type Definitions

Expand Down
9 changes: 3 additions & 6 deletions docs/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,10 @@ Function that is invoked when the `WebView` loading starts or ends.

### `originWhitelist`

List of origin strings to allow being navigated to. The strings allow wildcards and get matched against *just* the origin (not the full URL).
If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS.
The default whitelisted origins are "http://*" and "https://*".
List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _just_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://*" and "https://*".

| Type | Required |
| ---------------- | -------- |
| ---------------- | -------- |
| array of strings | No |

---
Expand Down Expand Up @@ -413,8 +411,7 @@ Boolean value that determines whether scrolling is enabled in the `WebView`. The

### `geolocationEnabled`

Set whether Geolocation is enabled in the `WebView`. The default value is `false`.
Used only in Android.
Set whether Geolocation is enabled in the `WebView`. The default value is `false`. Used only in Android.

| Type | Required | Platform |
| ---- | -------- | -------- |
Expand Down
10 changes: 6 additions & 4 deletions website/blog/2018-05-07-using-typescript-with-react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ export class Hello extends React.Component<Props, State> {
}

this.state = {
enthusiasmLevel: props.enthusiasmLevel || 1
enthusiasmLevel: props.enthusiasmLevel || 1,
};
}

onIncrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel + 1 });
onDecrement = () => this.setState({ enthusiasmLevel: this.state.enthusiasmLevel - 1 });
getExclamationMarks = (numChars: number) => Array(numChars + 1).join("!")
onIncrement = () =>
this.setState({enthusiasmLevel: this.state.enthusiasmLevel + 1});
onDecrement = () =>
this.setState({enthusiasmLevel: this.state.enthusiasmLevel - 1});
getExclamationMarks = (numChars: number) => Array(numChars + 1).join('!');

render() {
return (
Expand Down
6 changes: 3 additions & 3 deletions website/versioned_docs/version-0.54/keyboardavoidingview.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The style of the content container(View) when behavior is 'position'.

Enabled or disabled KeyboardAvoidingView.

| Type | Required |
| ---------- | -------- |
| boolean | Yes |
| Type | Required |
| ------- | -------- |
| boolean | Yes |

## Methods

Expand Down
6 changes: 3 additions & 3 deletions website/versioned_docs/version-0.55/keyboardavoidingview.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The style of the content container(View) when behavior is 'position'.

Enabled or disabled KeyboardAvoidingView.

| Type | Required |
| ---------- | -------- |
| boolean | Yes |
| Type | Required |
| ------- | -------- |
| boolean | Yes |

## Methods

Expand Down
25 changes: 14 additions & 11 deletions website/versioned_docs/version-0.55/sectionlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ A performant interface for rendering sectioned lists, supporting the most handy

If you don't need section support and want a simpler interface, use [`<FlatList>`](flatlist.md).

Simple Examples:
Simple Examples:

```javascript
// Example 1 (Homogeneous Rendering)
<SectionList
renderItem={({ item, index, section }) => <Text key={index}>{item}</Text>}
renderSectionHeader={({ section: { title } }) => <Text style={{ fontWeight: 'bold' }}>{title}</Text>}
sections={[
{ title: 'Title1', data: ['item1', 'item2'] },
{ title: 'Title2', data: ['item3', 'item4'] },
{ title: 'Title3', data: ['item5', 'item6'] },
]}
keyExtractor={(item, index) => item + index} />
// Example 1 (Homogeneous Rendering)
<SectionList
renderItem={({item, index, section}) => <Text key={index}>{item}</Text>}
renderSectionHeader={({section: {title}}) => (
<Text style={{fontWeight: 'bold'}}>{title}</Text>
)}
sections={[
{title: 'Title1', data: ['item1', 'item2']},
{title: 'Title2', data: ['item3', 'item4']},
{title: 'Title3', data: ['item5', 'item6']},
]}
keyExtractor={(item, index) => item + index}
/>
```

```javascript
Expand Down

0 comments on commit 85df282

Please sign in to comment.