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/components/Input.tsx | 4 +--- src/services/transfers/TransfersUpload.tsx | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 298d14c..a8a6f31 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -3,19 +3,17 @@ import { Field } from 'formik'; export interface Props extends React.InputHTMLAttributes { label?: string; - ref?: React.Ref } const focusStyles = 'focus:outline-none focus:shadow focus:border-gray-400'; const baseStyles = 'p-2 border bg-white border-gray-300 rounded-sm'; -const InputBase: React.FC = ({ label, ref, ...props }) => { +const InputBase: React.FC = ({ label, ...props }) => { return (
{ 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