I am trying to make an upload button to upload image. Before submitting, I want to display the image as soon as it is selected.
I am using material-ui library for react. Below is what I have tried, but as soon as I select a new image, the image element get destroyed from DOM.
constructor(props){
super(props);
this.state={
newImage:'https://seeklogo.com/images/I/instagram-new-2016-logo-4773FE3F99-seeklogo.com.png',
}
}
. . .
<Avatar
alt="Selected Image"
src={this.state.newImage}
className={classes.bigAvatar}
/>
<RaisedButton
<input
type="file"
onChange = {(event,newValue) => this.setState({newImage:newValue})}
/>
</RaisedButton>