mirror of
https://github.com/coaidev/coai.git
synced 2025-06-07 22:30:17 +09:00
fix: fix life cycle oi number-input (#62)
This commit is contained in:
parent
55d0fd8721
commit
31e1eaa684
@ -17,7 +17,8 @@ const NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(
|
|||||||
({ className, type, ...props }, ref) => {
|
({ className, type, ...props }, ref) => {
|
||||||
const [value, setValue] = useState(props.value.toString());
|
const [value, setValue] = useState(props.value.toString());
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getValue(props.value.toString()) !== props.value) {
|
// fix life cycle: update value when props.value changed
|
||||||
|
if (getValue(value.toString()) !== props.value) {
|
||||||
setValue(props.value.toString());
|
setValue(props.value.toString());
|
||||||
}
|
}
|
||||||
}, [props.value]);
|
}, [props.value]);
|
||||||
|
Loading…
Reference in New Issue
Block a user