Fix the ID update bug.

This commit is contained in:
Manuel Friedli 2023-04-16 01:01:23 +02:00
parent 46c16b8bc7
commit 4b300004b9
4 changed files with 8 additions and 11 deletions

View file

@ -3,7 +3,7 @@ import React, {useState} from 'react';
export default function ValidatingInputNumberField({
id,
label,
defaultValue = 0,
value = 0,
constraints = {},
validatorFn = (value) => {
return {valid: true, value};
@ -13,7 +13,6 @@ export default function ValidatingInputNumberField({
}
}) {
const [error, setError] = useState(null);
const [value, setValue] = useState(defaultValue);
const handleValueChange = (e) => {
const value = e.target.value;
@ -22,9 +21,8 @@ export default function ValidatingInputNumberField({
setError(validation.message);
} else {
setError(null);
onChange(validation.value);
}
setValue(validation.value);
onChange(validation.value);
};
let errorComponent;
if (!!error) {