Organize components, use webpack import aliases
This commit is contained in:
parent
f174d98107
commit
86c5451edb
50 changed files with 269 additions and 133 deletions
|
@ -1,27 +0,0 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
|
||||
export default class FileInput extends PureComponent {
|
||||
componentWillMount() {
|
||||
this.input = window.document.createElement('input');
|
||||
this.input.setAttribute('type', 'file');
|
||||
|
||||
this.input.addEventListener('change', e => {
|
||||
const file = e.target.files[0];
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = () => {
|
||||
this.props.onChange(file.name, reader.result);
|
||||
};
|
||||
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
||||
|
||||
handleClick = () => this.input.click();
|
||||
|
||||
render() {
|
||||
return (
|
||||
<button className="input-file" onClick={this.handleClick}>{this.props.name}</button>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue