Skip to content

Commit 7a16457

Browse files
authored
Merge pull request #129 from benny-medflyt/fix-nan-slider
Fix bug where slider value can become NaN
2 parents 1a4ba39 + 72a8229 commit 7a16457

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

react-slider.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,13 @@
491491
zIndices.splice(zIndices.indexOf(i), 1); // remove wherever the element is
492492
zIndices.push(i); // add to end
493493

494-
this.setState({
495-
startValue: this.state.value[i],
496-
startPosition: position,
497-
index: i,
498-
zIndices: zIndices
494+
this.setState(function (prevState) {
495+
return {
496+
startValue: this.state.value[i],
497+
startPosition: position !== undefined ? position : prevState.startPosition,
498+
index: i,
499+
zIndices: zIndices
500+
};
499501
});
500502
},
501503

0 commit comments

Comments
 (0)