Skip to content

Commit 7b6384d

Browse files
committed
ui-core: allow slider to be updated front the outside
Signed-off-by: Valentin Chanas <[email protected]>
1 parent f3bb01f commit 7b6384d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ui-core/src/components/inputs/Slider.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import type { ChangeEvent, MouseEvent, InputHTMLAttributes } from 'react';
33

44
import cx from 'classnames';
@@ -25,6 +25,10 @@ const Slider = ({
2525
initialValue !== undefined ? Number(initialValue) : Number(min)
2626
);
2727

28+
useEffect(() => {
29+
setValue(Number(initialValue));
30+
}, [initialValue]);
31+
2832
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
2933
const newValue = Number(e.target.value);
3034
setValue(newValue);

ui-core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export { default as RadioGroup, RadioGroupProps } from './components/inputs/Radi
2424
export { default as Select, SelectProps } from './components/Select';
2525
export { default as TextArea, TextAreaProps } from './components/inputs/TextArea';
2626
export { default as TimePicker } from './components/inputs/TimePicker';
27+
export { default as Slider } from './components/inputs/Slider';
2728
export {
2829
default as TolerancePicker,
2930
type TolerancePickerProps,

0 commit comments

Comments
 (0)