Skip to content

Commit a536b64

Browse files
Fixed props.children dependency in componentWillReceiveProps. Issue zillow#59.
1 parent b1e7325 commit a536b64

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

react-slider.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
// Keep the internal `value` consistent with an outside `value` if present.
219219
// This basically allows the slider to be a controlled component.
220220
componentWillReceiveProps: function (newProps) {
221-
var value = this._or(ensureArray(newProps.value), this.state.value);
221+
var value = this._or(ensureArray(newProps.value), this.state.value, newProps.children);
222222

223223
// ensure the array keeps the same size as `value`
224224
this.tempArray = value.slice();
@@ -241,8 +241,9 @@
241241
// If custom handles are present but neither `value` nor `defaultValue` are applicable the handles are spread out
242242
// equally.
243243
// TODO: better name? better solution?
244-
_or: function (value, defaultValue) {
245-
var count = React.Children.count(this.props.children);
244+
_or: function (value, defaultValue, children) {
245+
children = children || this.props.children;
246+
var count = React.Children.count(children);
246247
switch (count) {
247248
case 0:
248249
return value.length > 0 ? value : defaultValue;

0 commit comments

Comments
 (0)