Last active
October 13, 2021 03:51
-
-
Save hunzo/72910e784b5a29c65c223e931c7ad296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import './App.css' | |
function App() { | |
const handleFile = (e: React.ChangeEvent<HTMLInputElement>) => { | |
// if (!e.target.files) return // solv #1 remove null FileList | null | |
const files = e.target.files! // solv #2 it will not be null, trust me". haha | |
Array.from(files).forEach(async (f) => console.log(f)) | |
} | |
return ( | |
<div className="App"> | |
<input | |
multiple | |
type="file" | |
name="file" | |
id="file-upload" | |
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | |
handleFile(e) | |
} | |
/> | |
<button>submit</button> | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment