Skip to content

Commit

Permalink
fix(Slider): Update state when properties are updated. (patternfly#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce authored and jeff-phillips-18 committed Jan 25, 2019
1 parent abab0d4 commit 033a38b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ class Slider extends React.Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.value !== this.props.value) {
this.onSlide(this.props.value);
}
}

onSlide = value => {
this.setState({ value }, () => this.props.onSlide(value));
};

onInputChange = event => {
this.setState({ value: parseInt(event.target.value || 0, 10) });
const newValue = parseInt(event.target.value || 0, 10);
this.setState({ value: newValue }, () => this.props.onSlide(newValue));
};

onFormatChange = format => {
Expand Down

0 comments on commit 033a38b

Please sign in to comment.