diff --git a/packages/orbit-components/src/Slider/index.tsx b/packages/orbit-components/src/Slider/index.tsx index 982c0d916f..f73e8ded45 100644 --- a/packages/orbit-components/src/Slider/index.tsx +++ b/packages/orbit-components/src/Slider/index.tsx @@ -106,19 +106,19 @@ const PureSlider = ({ const [focused, setFocused] = React.useState(false); const { rtl } = theme; + const updateValue = (newValue: Value) => { + valueRef.current = newValue; + setValue(newValue); + }; + React.useEffect(() => { const newValue = Array.isArray(defaultValue) ? defaultValue.map(item => Number(item)) : Number(defaultValue); - setValue(newValue); + updateValue(newValue); }, [defaultValue]); - const updateValue = (newValue: Value) => { - valueRef.current = newValue; - setValue(newValue); - }; - const handleKeyDown = (event: KeyboardEvent) => { if (event.ctrlKey || event.shiftKey || event.altKey) return; const eventCode = Number(event.code);