I'm using a form control component to pass an image to an API endpoint via an AJAX call. So far, I'm unable to find information on how to actually target the actual file data.
2 Answers
I'm using TypeScript, and I kept getting the error Property 'files' does not exist on type 'EventTarget & FormControlElement'. Including the following types solved the issue:
const [thumbnail, setThumbnail] = useState<FileList | null>(null);
...
<Form.Control type="file" onChange={(e: React.ChangeEvent<HTMLInputElement>) => setThumbnail(e.target.files)} />