Skip to content

Commit

Permalink
Increased Prettier line-width for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Feb 7, 2018
1 parent 06d5be4 commit 3696388
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 74 deletions.
9 changes: 2 additions & 7 deletions examples/16-3-release-blog-create-ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ class MyComponent extends React.Component {
divRef = React.createRef();

render() {
// highlight-range{4}
return (
<input
type="text"
ref={this.divRef}
/>
);
// highlight-next-line
return <input type="text" ref={this.divRef} />;
}

componentDidMount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// After
class ExampleComponent extends React.Component {
// highlight-range{1-4}
// highlight-range{1-3}
state = {
subscribedValue: this.props
.dataSource.value,
subscribedValue: this.props.dataSource.value,
};

// highlight-range{1-19}
// highlight-range{1-18}
componentDidMount() {
// Event listeners are only safe to add after mount,
// So they won't leak if mount is interrupted or errors.
Expand All @@ -21,8 +20,7 @@ class ExampleComponent extends React.Component {
this.props.dataSource.value
) {
this.setState({
subscribedValue: this.props
.dataSource.value,
subscribedValue: this.props.dataSource.value,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Before
class ExampleComponent extends React.Component {
// highlight-range{1-11}
// highlight-range{1-10}
componentWillMount() {
this.setState({
subscribedValue: this.props
.dataSource.value,
subscribedValue: this.props.dataSource.value,
});

// This is not safe; it can leak!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ class ExampleComponent extends React.Component {
externalData: null,
};

// highlight-range{1-9}
// highlight-range{1-7}
componentDidMount() {
asyncLoadData(
this.props.someId
).then(externalData => {
asyncLoadData(this.props.someId).then(externalData => {
if (!this._hasUnmounted) {
this.setState({externalData});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ class ExampleComponent extends React.Component {
externalData: null,
};

// highlight-range{1-7}
// highlight-range{1-5}
componentWillMount() {
asyncLoadData(
this.props.someId
).then(externalData =>
asyncLoadData(this.props.someId).then(externalData =>
this.setState({externalData})
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// After
class ExampleComponent extends React.Component {
// highlight-range{1-5}
// highlight-range{1-4}
state = {
currentColor: this.props
.defaultColor,
currentColor: this.props.defaultColor,
palette: 'rgb',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
class ExampleComponent extends React.Component {
state = {};

// highlight-range{1-7}
// highlight-range{1-6}
componentWillMount() {
this.setState({
currentColor: this.props
.defaultColor,
currentColor: this.props.defaultColor,
palette: 'rgb',
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// After
class ExampleComponent extends React.Component {
// highlight-next-line
componentDidUpdate(
prevProps,
prevState
) {
// highlight-range{1-8}
// highlight-range{1-8}
componentDidUpdate(prevProps, prevState) {
if (
this.state.someStatefulValue !==
prevState.someStatefulValue
) {
this.props.onChange(
this.state.someStatefulValue
);
this.props.onChange(this.state.someStatefulValue);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
// Before
class ExampleComponent extends React.Component {
// highlight-next-line
componentWillUpdate(
nextProps,
nextState
) {
// highlight-range{1-8}
// highlight-range{1-8}
componentWillUpdate(nextProps, nextState) {
if (
this.state.someStatefulValue !==
nextState.someStatefulValue
) {
nextProps.onChange(
nextState.someStatefulValue
);
nextProps.onChange(nextState.someStatefulValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ class TopLevelRoute extends React.Component {
constructor(props) {
super(props);

SharedApplicationState.recordEvent(
'ExampleComponent'
);
SharedApplicationState.recordEvent('ExampleComponent');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ class ExampleComponent extends React.Component {
// highlight-next-line
state = {};

// highlight-next-line
static getDerivedStateFromProps(
nextProps,
prevState
) {
// highlight-range{1-11}
if (
nextProps.currentRow !==
prevState.lastRow
) {
// highlight-range{1-8}
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.currentRow !== prevState.lastRow) {
return {
lastRow: nextProps.currentRow,
isScrollingDown:
nextProps.currentRow >
prevState.lastRow,
nextProps.currentRow > prevState.lastRow,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ class ExampleComponent extends React.Component {
isScrollingDown: false,
};

// highlight-range{1-12}
// highlight-range{1-8}
componentWillReceiveProps(nextProps) {
if (
this.props.currentRow !==
nextProps.currentRow
) {
if (this.props.currentRow !== nextProps.currentRow) {
this.setState({
isScrollingDown:
nextProps.currentRow >
this.props.currentRow,
nextProps.currentRow > this.props.currentRow,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import polyfill from 'react-lifecycles-compat';

class ExampleComponent extends React.Component {
// highlight-next-line
static getDerivedStateFromProps(
nextProps,
prevState
) {
static getDerivedStateFromProps(nextProps, prevState) {
// Your state update logic here ...
}
}
Expand Down

0 comments on commit 3696388

Please sign in to comment.