spacedrive/interface/hooks/useInputState.tsx

11 lines
280 B
TypeScript
Raw Normal View History

2022-09-08 23:32:13 +00:00
import { useState } from 'react';
2022-04-17 18:44:34 +00:00
export function useInputState<T = any>(initialValue: T) {
2022-05-23 07:54:46 +00:00
const [value, setValue] = useState<T>(initialValue);
return {
onChange: (event: React.ChangeEvent<HTMLInputElement>) =>
setValue(event.target.value as unknown as T),
value
};
2022-04-17 18:44:34 +00:00
}