2016-05-30 16:55:32 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
export default class ImagePreview extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-06-05 23:22:12 -03:00
|
|
|
this.handleImageLoaded = this.handleImageLoaded.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleImageLoaded() {
|
2016-06-05 23:37:19 -03:00
|
|
|
window.URL.revokeObjectURL(this.props.value);
|
2016-05-30 16:55:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-06-05 23:37:19 -03:00
|
|
|
console.log(this.props)
|
2016-05-30 16:55:32 -07:00
|
|
|
const { value } = this.props;
|
2016-06-05 23:22:12 -03:00
|
|
|
return value ? <img src={window.URL.createObjectURL(value)} onLoad={this.handleImageLoaded} /> : null;
|
2016-05-30 16:55:32 -07:00
|
|
|
}
|
|
|
|
}
|