Skip to content

Commit

Permalink
fix: fix life cycle oi number-input (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Jan 30, 2024
1 parent 55d0fd8 commit 31e1eaa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/components/ui/number-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 31e1eaa

Please sign in to comment.