From 907da06c18b8219f774459f7810116009709e0c1 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 26 Mar 2021 02:29:54 +0300 Subject: fix: use state instead of refs --- src/services/transfers/TransfersUpload.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/services') diff --git a/src/services/transfers/TransfersUpload.tsx b/src/services/transfers/TransfersUpload.tsx index 56bcd7e..3a867aa 100644 --- a/src/services/transfers/TransfersUpload.tsx +++ b/src/services/transfers/TransfersUpload.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from 'react'; +import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; import { Form, Formik } from 'formik'; import Input from '../../components/Input'; @@ -8,11 +8,14 @@ import { post } from '../../requests'; const TransfersUpload: React.FC = () => { const history = useHistory(); - const inputRef = useRef(null); + const [file, setFile] = useState(); + + const handleChange = (event: React.ChangeEvent) => { + setFile(event.target?.files?.[0]); + }; const handleSubmitFile = () => { const reader = new FileReader(); - const file = inputRef?.current?.files?.[0]; if (file) { reader.readAsDataURL(file); reader.onload = (event: ProgressEvent) => { @@ -34,7 +37,13 @@ const TransfersUpload: React.FC = () => { >
- +
-- cgit v1.2.3