mirror of
https://github.com/coaidev/coai.git
synced 2025-06-01 11:20:26 +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) => {
|
||||
const [value, setValue] = useState(props.value.toString());
|
||||
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());
|
||||
}
|
||||
}, [props.value]);
|
||||
|
Loading…
Reference in New Issue
Block a user