From 2cb0dbce6fe80032d030a344e72fa82dd00465a3 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Sat, 30 Jan 2016 18:52:12 +0800 Subject: [PATCH] fix: work with rc-form --- package.json | 2 +- src/Slider.jsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index cab75d6..298acc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-slider", - "version": "3.3.1", + "version": "3.3.2", "description": "slider ui component for react", "keywords": [ "react", diff --git a/src/Slider.jsx b/src/Slider.jsx index b5a234d..95fc982 100644 --- a/src/Slider.jsx +++ b/src/Slider.jsx @@ -34,7 +34,7 @@ class Slider extends React.Component { const {range, min, max} = props; const initialValue = range ? [min, min] : min; const defaultValue = ('defaultValue' in props ? props.defaultValue : initialValue); - const value = ('value' in props ? props.value : defaultValue); + const value = (props.value !== undefined ? props.value : defaultValue); let upperBound; let lowerBound; @@ -81,11 +81,11 @@ class Slider extends React.Component { lowerBound: nextLowerBound, }); if (this.isValueOutOfBounds(upperBound, nextProps) || - this.isValueOutOfBounds(lowerBound, nextProps)) { + this.isValueOutOfBounds(lowerBound, nextProps)) { this.props.onChange([nextLowerBound, nextUpperBound]); } } else { - const value = 'value' in nextProps ? nextProps.value : upperBound; + const value = nextProps.value !== undefined ? nextProps.value : upperBound; const nextValue = this.trimAlignValue(value, nextProps); if (nextValue === upperBound && lowerBound === nextProps.min) return; @@ -333,7 +333,7 @@ class Slider extends React.Component { render() { const {handle, upperBound, lowerBound} = this.state; const {className, prefixCls, disabled, dots, included, range, step, - marks, max, min, tipTransitionName, tipFormatter, children} = this.props; + marks, max, min, tipTransitionName, tipFormatter, children} = this.props; const upperOffset = this.calcOffset(upperBound); const lowerOffset = this.calcOffset(lowerBound); @@ -343,13 +343,13 @@ class Slider extends React.Component { const upper = (); + offset={upperOffset} value={upperBound} dragging={handle === 'upperBound'}/>); let lower = null; if (range) { lower = (); + offset={lowerOffset} value={lowerBound} dragging={handle === 'lowerBound'}/>); } const sliderClassName = classNames({ @@ -368,10 +368,10 @@ class Slider extends React.Component { offset={lowerOffset} length={upperOffset - lowerOffset}/> + upperBound={upperBound} max={max} min={min}/> + upperBound={upperBound} max={max} min={min}/> {children} );