diff --git a/src/Slider.jsx b/src/Slider.jsx index beed01d..5f08f73 100644 --- a/src/Slider.jsx +++ b/src/Slider.jsx @@ -5,6 +5,7 @@ import Track from './Track'; import DefaultHandle from './Handle'; import Steps from './Steps'; import Marks from './Marks'; +import warning from 'warning'; function noop() { } @@ -30,7 +31,7 @@ class Slider extends React.Component { constructor(props) { super(props); - const { range, min, max } = props; + const { range, min, max, step } = props; const initialValue = range ? Array.apply(null, Array(range + 1)).map(() => min) : min; const defaultValue = ('defaultValue' in props ? props.defaultValue : initialValue); const value = (props.value !== undefined ? props.value : defaultValue); @@ -44,6 +45,15 @@ class Slider extends React.Component { recent = bounds.length - 1; } + if (process.env.NODE_ENV !== 'production' && (max - min) % step !== 0) { + warning( + false, + 'Slider[max] - Slider[min] (%s) should be a multiple of Slider[step] (%s)', + max - min, + step + ); + } + this.state = { handle: null, recent,