mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Increased Prettier line-width for examples
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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});
|
||||
}
|
||||
|
||||
@@ -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})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ class TopLevelRoute extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
SharedApplicationState.recordEvent(
|
||||
'ExampleComponent'
|
||||
);
|
||||
SharedApplicationState.recordEvent('ExampleComponent');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ...
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user