This commit is contained in:
azizziy
2025-05-20 17:02:10 +05:00
commit c01e852a59
257 changed files with 27766 additions and 0 deletions

22
src/hooks/useInput.ts Normal file
View File

@@ -0,0 +1,22 @@
import { ChangeEvent, useState } from 'react';
/**
* This hook allows you to handle state for inputs
* @param {number} initialValue - initial value for useState
* @returns {object} object that should be used for managing inputs
*/
const useInput = (initialValue: string) => {
const [value, setValue] = useState(initialValue);
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setValue(event.target.value);
};
return {
value,
onChange: handleChange,
setValue,
};
};
export default useInput;