mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
17 lines
420 B
TypeScript
17 lines
420 B
TypeScript
import { type ChangeEvent, useCallback } from 'react';
|
|
|
|
export function useUpdateInputValue(onValueChanged: (val: string) => void, disabled?: boolean) {
|
|
return useCallback(
|
|
(e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
|
if (disabled) {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
const val = e.target.value;
|
|
|
|
onValueChanged(val);
|
|
},
|
|
[disabled, onValueChanged]
|
|
);
|
|
}
|