Skip to content

Commit 856dc98

Browse files
JoelMarceyMorgan Pretty
authored andcommitted
Add extends Component to Dimensions and Layout Basics Examples
Summary: It works without out the `extends`, but I do not really understand why, unless there is some magic implicit `extends` if you don't put it and you call `registerComponent`. But, I figure we should be explicit unless there is a good reason not to be. Closes facebook#8377 Differential Revision: D3478950 Pulled By: JoelMarcey fbshipit-source-id: 05ea4367c3c8c34aea6c092639ee51d8761bca3f
1 parent 57ece23 commit 856dc98

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

docs/Basics-Dimensions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ A component's dimensions determine its size on the screen.
1414
The simplest way to set the dimensions of a component is by adding a fixed `width` and `height` to style. All dimensions in React Native are unitless, and represent density-independent pixels.
1515

1616
```ReactNativeWebPlayer
17-
import React from 'react';
17+
import React, { Component } from 'react';
1818
import { AppRegistry, View } from 'react-native';
1919
20-
class AwesomeProject {
20+
class FixedDimensionsBasics extends Component {
2121
render() {
2222
return (
2323
<View>
@@ -29,7 +29,7 @@ class AwesomeProject {
2929
}
3030
};
3131
32-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
32+
AppRegistry.registerComponent('AwesomeProject', () => FixedDimensionsBasics);
3333
```
3434

3535
Setting dimensions this way is common for components that should always render at exactly the same size, regardless of screen dimensions.
@@ -41,10 +41,10 @@ Use `flex` in a component's style to have the component expand and shrink dynami
4141
> A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed `width` and `height` or `flex`, the parent will have dimensions of 0 and the `flex` children will not be visible.
4242
4343
```ReactNativeWebPlayer
44-
import React from 'react';
44+
import React, { Component } from 'react';
4545
import { AppRegistry, View } from 'react-native';
4646
47-
class AwesomeProject {
47+
class FlexDimensionsBasics extends Component {
4848
render() {
4949
return (
5050
// Try removing the `flex: 1` on the parent View.
@@ -59,5 +59,5 @@ class AwesomeProject {
5959
}
6060
};
6161
62-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
62+
AppRegistry.registerComponent('AwesomeProject', () => FlexDimensionsBasics);
6363
```

docs/Basics-Layout.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ You will normally use a combination of `flexDirection`, `alignItems`, and `justi
1818
Adding `flexDirection` to a component's `style` determines the **primary axis** of its layout. Should the children be organized horizontally (`row`) or vertically (`column`)? The default is `column`.
1919

2020
```ReactNativeWebPlayer
21-
import React from 'react';
21+
import React, { Component } from 'react';
2222
import { AppRegistry, View } from 'react-native';
2323
24-
class AwesomeProject {
24+
class FlexDirectionBasics extends Component {
2525
render() {
2626
return (
2727
// Try setting `flexDirection` to `column`.
@@ -34,18 +34,18 @@ class AwesomeProject {
3434
}
3535
};
3636
37-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
37+
AppRegistry.registerComponent('AwesomeProject', () => FlexDirectionBasics);
3838
```
3939

4040
#### Justify Content
4141

4242
Adding `justifyContent` to a component's style determines the **distribution** of children along the **primary axis**. Should children be distributed at the start, the center, the end, or spaced evenly? Available options are `flex-start`, `center`, `flex-end`, `space-around`, and `space-between`.
4343

4444
```ReactNativeWebPlayer
45-
import React from 'react';
45+
import React, { Component } from 'react';
4646
import { AppRegistry, View } from 'react-native';
4747
48-
class AwesomeProject {
48+
class JustifyContentBasics extends Component {
4949
render() {
5050
return (
5151
// Try setting `justifyContent` to `center`.
@@ -63,7 +63,7 @@ class AwesomeProject {
6363
}
6464
};
6565
66-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
66+
AppRegistry.registerComponent('AwesomeProject', () => JustifyContentBasics);
6767
```
6868

6969
#### Align Items
@@ -73,10 +73,10 @@ Adding `alignItems` to a component's style determines the **alignment** of child
7373
> For `stretch` to have an effect, children must not have a fixed dimension along the secondary axis. In the following example, setting `alignItems: stretch` does nothing until the `width: 50` is removed from the children.
7474
7575
```ReactNativeWebPlayer
76-
import React from 'react';
76+
import React, { Component } from 'react';
7777
import { AppRegistry, View } from 'react-native';
7878
79-
class AwesomeProject {
79+
class AlignItemsBasics {
8080
render() {
8181
return (
8282
// Try setting `alignItems` to 'flex-start'
@@ -96,7 +96,7 @@ class AwesomeProject {
9696
}
9797
};
9898
99-
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
99+
AppRegistry.registerComponent('AwesomeProject', () => AlignItemsBasics);
100100
```
101101

102102
#### API Reference

0 commit comments

Comments
 (0)