mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-23 07:04:22 +00:00
21 lines
No EOL
447 B
TypeScript
21 lines
No EOL
447 B
TypeScript
import { ChangeEvent, useCallback, useState } from "react";
|
|
|
|
|
|
type FileState = {
|
|
value: string,
|
|
file: File | null,
|
|
}
|
|
|
|
|
|
export function useFilePickerState() {
|
|
const [state, setState] = useState<FileState>({ value: "", file: null })
|
|
|
|
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
setState({
|
|
value: e.target.value,
|
|
file: e.target.files![0],
|
|
})
|
|
}
|
|
|
|
return { state, onChange }
|
|
} |