Skip to content

Commit 3696388

Browse files
committed
Increased Prettier line-width for examples
1 parent 06d5be4 commit 3696388

13 files changed

+31
-74
lines changed

examples/16-3-release-blog-create-ref.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ class MyComponent extends React.Component {
33
divRef = React.createRef();
44

55
render() {
6-
// highlight-range{4}
7-
return (
8-
<input
9-
type="text"
10-
ref={this.divRef}
11-
/>
12-
);
6+
// highlight-next-line
7+
return <input type="text" ref={this.divRef} />;
138
}
149

1510
componentDidMount() {

examples/update-on-async-rendering/adding-event-listeners-after.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// After
22
class ExampleComponent extends React.Component {
3-
// highlight-range{1-4}
3+
// highlight-range{1-3}
44
state = {
5-
subscribedValue: this.props
6-
.dataSource.value,
5+
subscribedValue: this.props.dataSource.value,
76
};
87

9-
// highlight-range{1-19}
8+
// highlight-range{1-18}
109
componentDidMount() {
1110
// Event listeners are only safe to add after mount,
1211
// So they won't leak if mount is interrupted or errors.
@@ -21,8 +20,7 @@ class ExampleComponent extends React.Component {
2120
this.props.dataSource.value
2221
) {
2322
this.setState({
24-
subscribedValue: this.props
25-
.dataSource.value,
23+
subscribedValue: this.props.dataSource.value,
2624
});
2725
}
2826
}

examples/update-on-async-rendering/adding-event-listeners-before.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Before
22
class ExampleComponent extends React.Component {
3-
// highlight-range{1-11}
3+
// highlight-range{1-10}
44
componentWillMount() {
55
this.setState({
6-
subscribedValue: this.props
7-
.dataSource.value,
6+
subscribedValue: this.props.dataSource.value,
87
});
98

109
// This is not safe; it can leak!

examples/update-on-async-rendering/fetching-external-data-after.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ class ExampleComponent extends React.Component {
77
externalData: null,
88
};
99

10-
// highlight-range{1-9}
10+
// highlight-range{1-7}
1111
componentDidMount() {
12-
asyncLoadData(
13-
this.props.someId
14-
).then(externalData => {
12+
asyncLoadData(this.props.someId).then(externalData => {
1513
if (!this._hasUnmounted) {
1614
this.setState({externalData});
1715
}

examples/update-on-async-rendering/fetching-external-data-before.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ class ExampleComponent extends React.Component {
44
externalData: null,
55
};
66

7-
// highlight-range{1-7}
7+
// highlight-range{1-5}
88
componentWillMount() {
9-
asyncLoadData(
10-
this.props.someId
11-
).then(externalData =>
9+
asyncLoadData(this.props.someId).then(externalData =>
1210
this.setState({externalData})
1311
);
1412
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// After
22
class ExampleComponent extends React.Component {
3-
// highlight-range{1-5}
3+
// highlight-range{1-4}
44
state = {
5-
currentColor: this.props
6-
.defaultColor,
5+
currentColor: this.props.defaultColor,
76
palette: 'rgb',
87
};
98
}

examples/update-on-async-rendering/initializing-state-before.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
class ExampleComponent extends React.Component {
33
state = {};
44

5-
// highlight-range{1-7}
5+
// highlight-range{1-6}
66
componentWillMount() {
77
this.setState({
8-
currentColor: this.props
9-
.defaultColor,
8+
currentColor: this.props.defaultColor,
109
palette: 'rgb',
1110
});
1211
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
// After
22
class ExampleComponent extends React.Component {
3-
// highlight-next-line
4-
componentDidUpdate(
5-
prevProps,
6-
prevState
7-
) {
8-
// highlight-range{1-8}
3+
// highlight-range{1-8}
4+
componentDidUpdate(prevProps, prevState) {
95
if (
106
this.state.someStatefulValue !==
117
prevState.someStatefulValue
128
) {
13-
this.props.onChange(
14-
this.state.someStatefulValue
15-
);
9+
this.props.onChange(this.state.someStatefulValue);
1610
}
1711
}
1812
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
// Before
22
class ExampleComponent extends React.Component {
3-
// highlight-next-line
4-
componentWillUpdate(
5-
nextProps,
6-
nextState
7-
) {
8-
// highlight-range{1-8}
3+
// highlight-range{1-8}
4+
componentWillUpdate(nextProps, nextState) {
95
if (
106
this.state.someStatefulValue !==
117
nextState.someStatefulValue
128
) {
13-
nextProps.onChange(
14-
nextState.someStatefulValue
15-
);
9+
nextProps.onChange(nextState.someStatefulValue);
1610
}
1711
}
1812
}

examples/update-on-async-rendering/side-effects-in-constructor.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ class TopLevelRoute extends React.Component {
22
constructor(props) {
33
super(props);
44

5-
SharedApplicationState.recordEvent(
6-
'ExampleComponent'
7-
);
5+
SharedApplicationState.recordEvent('ExampleComponent');
86
}
97
}

examples/update-on-async-rendering/updating-state-from-props-after.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,13 @@ class ExampleComponent extends React.Component {
55
// highlight-next-line
66
state = {};
77

8-
// highlight-next-line
9-
static getDerivedStateFromProps(
10-
nextProps,
11-
prevState
12-
) {
13-
// highlight-range{1-11}
14-
if (
15-
nextProps.currentRow !==
16-
prevState.lastRow
17-
) {
8+
// highlight-range{1-8}
9+
static getDerivedStateFromProps(nextProps, prevState) {
10+
if (nextProps.currentRow !== prevState.lastRow) {
1811
return {
1912
lastRow: nextProps.currentRow,
2013
isScrollingDown:
21-
nextProps.currentRow >
22-
prevState.lastRow,
14+
nextProps.currentRow > prevState.lastRow,
2315
};
2416
}
2517

examples/update-on-async-rendering/updating-state-from-props-before.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ class ExampleComponent extends React.Component {
44
isScrollingDown: false,
55
};
66

7-
// highlight-range{1-12}
7+
// highlight-range{1-8}
88
componentWillReceiveProps(nextProps) {
9-
if (
10-
this.props.currentRow !==
11-
nextProps.currentRow
12-
) {
9+
if (this.props.currentRow !== nextProps.currentRow) {
1310
this.setState({
1411
isScrollingDown:
15-
nextProps.currentRow >
16-
this.props.currentRow,
12+
nextProps.currentRow > this.props.currentRow,
1713
});
1814
}
1915
}

examples/update-on-async-rendering/using-react-lifecycles-compat.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import polyfill from 'react-lifecycles-compat';
44

55
class ExampleComponent extends React.Component {
66
// highlight-next-line
7-
static getDerivedStateFromProps(
8-
nextProps,
9-
prevState
10-
) {
7+
static getDerivedStateFromProps(nextProps, prevState) {
118
// Your state update logic here ...
129
}
1310
}

0 commit comments

Comments
 (0)