static-cms/src/components/Widgets/ImagePreview.js

18 lines
431 B
JavaScript
Raw Normal View History

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