added a use effect to update the value in the time when the initial value in the component changes
This commit is contained in:
parent
b3245ad1bc
commit
b3569efc5f
1 changed files with 7 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue