Use File Reader
This is a React hook to use the FileReader api.
Usage
const MyComponent = { const result error loading setFile = const onInputFile = { } return <> loading ? <p>Reading file</p> : null error ? <p>errormessage</p> : null result ? <img src=result /> : null <input type="file" accept=".jpg,.png,.svg" onInput=onInputFile /> </> }
Options
method [String] - This is the read method you would use like: readAsText readAsDataURL. readAsText is the default. onload [Function] - This fire onload event of the reader. This parameter is the result of the file reader.