From b3569efc5fa224e0ecbb5b82bf7048bd5be62d7d Mon Sep 17 00:00:00 2001 From: csawatzky Date: Tue, 19 Aug 2025 14:24:55 -0600 Subject: [PATCH] added a use effect to update the value in the time when the initial value in the component changes --- src/common/time/PeriodSelect.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/time/PeriodSelect.tsx b/src/common/time/PeriodSelect.tsx index 66e4f9c..d510ebc 100644 --- a/src/common/time/PeriodSelect.tsx +++ b/src/common/time/PeriodSelect.tsx @@ -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);