Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(compat): upgrade RangeSlider lifecycle (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Jun 27, 2019
1 parent c3ba42d commit 69a7f53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions packages/react-instantsearch-dom/src/widgets/RangeSlider.js
Expand Up @@ -29,14 +29,17 @@ class Range extends React.Component {
state = { currentValues: { min: this.props.min, max: this.props.max } };
componentWillReceiveProps(sliderState) {
// @TODO: Derived State, maybe render
if (sliderState.canRefine) {
componentDidUpdate(prevProps) {
if (
this.props.canRefine &&
(prevProps.currentRefinement.min !== this.props.currentRefinement.min ||
prevProps.currentRefinement.max !== this.props.currentRefinement.max)
) {
this.setState({
currentValues: {
min: sliderState.currentRefinement.min,
max: sliderState.currentRefinement.max
}
min: this.props.currentRefinement.min,
max: this.props.currentRefinement.max,
},
});
}
}
Expand Down
13 changes: 8 additions & 5 deletions stories/3rdPartyIntegrations.stories.js
Expand Up @@ -29,13 +29,16 @@ class Range extends Component {

state = { currentValues: { min: this.props.min, max: this.props.max } };

componentWillReceiveProps(sliderState) {
// @TODO: Derived State, maybe render
if (sliderState.canRefine) {
componentDidUpdate(prevProps) {
if (
this.props.canRefine &&
(prevProps.currentRefinement.min !== this.props.currentRefinement.min ||
prevProps.currentRefinement.max !== this.props.currentRefinement.max)
) {
this.setState({
currentValues: {
min: sliderState.currentRefinement.min,
max: sliderState.currentRefinement.max,
min: this.props.currentRefinement.min,
max: this.props.currentRefinement.max,
},
});
}
Expand Down

0 comments on commit 69a7f53

Please sign in to comment.