This commit is contained in:
Samandar Turg'unboev
2025-05-29 12:36:30 +05:00
parent fe18f8a203
commit b96e7403d0
2 changed files with 35 additions and 25 deletions

View File

@@ -8,8 +8,12 @@ import { ChangeEvent, useState } from 'react';
const useInput = (initialValue: string) => {
const [value, setValue] = useState(initialValue);
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value);
const handleChange = (event: ChangeEvent<HTMLInputElement> | string) => {
if (typeof event === 'string') {
setValue(event);
} else if (event?.target) {
setValue(event.target.value);
}
};
return {