fix: fix life cycle oi number-input (#62)

This commit is contained in:
Zhang Minghan 2024-01-30 21:24:05 +08:00
parent 55d0fd8721
commit 31e1eaa684

View File

@ -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]);