type Props = { sendImage: SendImage; }; const PhotoUpload: React.FC<Props> = ({ sendImage }) => { const [file, setFile] = useState<File>(); const [description, setDescription] = useState(""); const handleSendPicture = useCallback( async (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { event.preventDefault(); await sendImage.send({ file, description, }); }, [sendImage, file, description] ); return ( <Container> // any jsx code <SubmitButton onClick={handleSendPicture}>Send</SubmitButton> </Container> ); }; export default PhotoUpload;