This commit is contained in:
Rizky 2024-02-07 21:28:48 +07:00
parent 77075096e6
commit 447b71576d
1 changed files with 13 additions and 5 deletions

View File

@ -17,7 +17,7 @@ export const FieldNumUnit: FC<{
icon,
value,
label,
update,
update: _update,
unit,
hideUnit,
width,
@ -35,6 +35,16 @@ export const FieldNumUnit: FC<{
timeout: null as any,
});
const update: typeof _update = useCallback(
(...arg) => {
clearTimeout(local.timeout);
local.timeout = setTimeout(() => {
_update(...arg);
}, 100);
},
[_update]
);
const parseVal = useCallback(() => {
let val = "";
let unt = "";
@ -83,12 +93,10 @@ export const FieldNumUnit: FC<{
local.val = Math.max(0, local.val);
}
local.val_str = local.val + "";
local.render();
clearTimeout(local.timeout);
local.timeout = setTimeout(() => {
update(local.val + local.unit);
}, 300);
}
};