Brian Vaughn
7 years ago
13 changed files with 31 additions and 74 deletions
@ -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', |
|||
}; |
|||
} |
|||
|
@ -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); |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue