added a use effect to update the value in the time when the initial value in the component changes

This commit is contained in:
csawatzky 2025-08-19 14:24:55 -06:00
parent b3245ad1bc
commit b3569efc5f

View file

@ -28,6 +28,13 @@ export default function PeriodSelect(props: Props) {
}
}, [unit, prevUnit, onChange, value]);
useEffect(()=>{
let initialUnit: TimeUnit = bestUnit(initialMs);
let initialValue = milliToX(initialMs, initialUnit).toString();
setValue(initialValue)
setUnit(initialUnit)
},[initialMs])
const changeValue = (event: any) => {
let value = event.target.value;
setValue(value);