Skip to content

Commit 6d8ce5f

Browse files
Provide currentValue with defined value of Slider
1 parent 027f600 commit 6d8ce5f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

package/src/Slider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const SliderComponent = (
211211
...localProps
212212
} = props;
213213
const [currentValue, setCurrentValue] = useState(
214-
props.value ?? props.minimumValue,
214+
props.value || props.minimumValue || constants.SLIDER_DEFAULT_INITIAL_VALUE,
215215
);
216216
const [width, setWidth] = useState(0);
217217

@@ -338,7 +338,7 @@ const SliderComponent = (
338338
const SliderWithRef = React.forwardRef(SliderComponent);
339339

340340
SliderWithRef.defaultProps = {
341-
value: 0,
341+
value: constants.SLIDER_DEFAULT_INITIAL_VALUE,
342342
minimumValue: 0,
343343
maximumValue: 1,
344344
step: 0,

package/src/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const constants = {
2+
SLIDER_DEFAULT_INITIAL_VALUE: 0,
23
MARGIN_HORIZONTAL_PADDING: 0.05,
34
STEP_NUMBER_TEXT_FONT_SMALL: 8,
45
STEP_NUMBER_TEXT_FONT_BIG: 12,

0 commit comments

Comments
 (0)