getting a file as local image and displaying it

PHOTO EMBED

Sun May 23 2021 13:58:44 GMT+0000 (Coordinated Universal Time)

Saved by @jatin_sachdeva #jsx

const React = require('react')
class Upload extends React.Component {
  constructor(props){
    super(props)
    this.state = {
      file: null
    }
    this.handleChange = this.handleChange.bind(this)
  }
  handleChange(event) {
    this.setState({
      file: URL.createObjectURL(event.target.files[0])
    })
  }
  render() {
    return (
      <div>
        <input type="file" onChange={this.handleChange}/>
        <img src={this.state.file}/>
      </div>
    );
  }
}
module.exports = Upload
content_copyCOPY

https://medium.com/@650egor/react-30-day-challenge-day-2-image-upload-preview-2d534f8eaaa