1const React = require('react')
2class Upload extends React.Component {
3 constructor(props){
4 super(props)
5 this.state = {
6 file: null
7 }
8 this.handleChange = this.handleChange.bind(this)
9 }
10 handleChange(event) {
11 this.setState({
12 file: URL.createObjectURL(event.target.files[0])
13 })
14 }
15 render() {
16 return (
17 <div>
18 <input type="file" onChange={this.handleChange}/>
19 <img src={this.state.file}/>
20 </div>
21 );
22 }
23}
24module.exports = Upload