mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
23 lines
651 B
TypeScript
23 lines
651 B
TypeScript
import * as React from 'react';
|
|
import FileReaderInput = require('react-file-reader-input');
|
|
|
|
class MyComponent extends React.Component {
|
|
handleChange = (event: React.SyntheticEvent<any>, results: FileReaderInput.Result[]) => {
|
|
results.forEach(result => {
|
|
const [event, file] = result;
|
|
console.log(`Selected file ${file.name}!`);
|
|
});
|
|
}
|
|
|
|
render(): React.ReactElement<{}> {
|
|
return (
|
|
<form>
|
|
<label htmlFor="my-file-input">Upload a File: </label>
|
|
<FileReaderInput as="binary" onChange={this.handleChange} >
|
|
<button>Select a file!</button>
|
|
</FileReaderInput>
|
|
</form>
|
|
);
|
|
}
|
|
}
|