Skip to content

Commit 7b86433

Browse files
JoelMarceyMorgan Pretty
authored andcommitted
ES6-ify View Basics
Summary: Closes facebook#8366 Differential Revision: D3477409 Pulled By: caabernathy fbshipit-source-id: 5906e8dffc7884a6ed527fada5f907702a72c08f
1 parent 087cf8a commit 7b86433

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

docs/Basics-Component-View.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ It is recommended that you wrap your components in a `View` to style and control
1616
The example below creates a `View` that aligns the `string` `Hello` in the top center of the device, something which could not be done with a `Text` component alone (i.e., a `Text` component without a `View` would place the `string` in a fixed location in the upper corner):
1717

1818
```ReactNativeWebPlayer
19-
import React from 'react';
19+
import React, { Component } from 'react';
2020
import { AppRegistry, Text, View } from 'react-native';
2121
22-
const AwesomeProject = () => {
23-
return (
24-
<View style={{marginTop: 22, alignItems: 'center'}}>
25-
<Text>Hello!</Text>
26-
</View>
27-
);
22+
class ViewBasics extends Component {
23+
render() {
24+
return (
25+
<View style={{marginTop: 22, alignItems: 'center'}}>
26+
<Text>Hello!</Text>
27+
</View>
28+
);
29+
}
2830
}
2931
3032
// App registration and rendering
31-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
33+
AppRegistry.registerComponent('AwesomeProject', () => ViewBasics);
3234
```

0 commit comments

Comments
 (0)