showing results for - "react useref file input"
Jesús
31 Sep 2019
1const App = () => {
2  const inputRef = useRef(null);
3  const [file, setFile] = useState(null);
4  return (
5    <>
6      <input
7        ref={inputRef}
8        accept=".pdf"
9        style={{ display: "none" }}
10        id="raised-button-file"
11        multiple
12        type="file"
13        onChange={e => {
14          setFile(e.target.files[0]);
15        }}
16      />
17      <label htmlFor="raised-button-file">
18        <button component="span">
19          <span>file</span>
20        </button>
21      </label>
22    </>
23  );
24};
25