}, }; this.updateDimensions = this.updateDimensions.bind(this); } updateDimensions({ target }) { this.setState({ dimensions: { width: target.naturalWidth, height: target.naturalHeight, }, }); } render() { const { mimeType, encoding, text, url } = this.props; const { width, height } = this.state.dimensions; return div( { className: "panel-container response-image-box devtools-monospace" }, img({ className: "response-image devtools-checkered-background", src: formDataURI(mimeType, encoding, text), onLoad: this.updateDimensions, }), div( { className: "response-summary" }, div({ className: "tabpanel-summary-label" }, RESPONSE_IMG_NAME), div({ className: "tabpanel-summary-value" }, getUrlBaseName(url)) ), div( { className: "response-summary" }, div({ className: "tabpanel-summary-label" }, RESPONSE_IMG_DIMENSIONS), div({ className: "tabpanel-summary-value" }, `${width} × ${height}`) ), div( { className: "response-summary" }, div({ className: "tabpanel-summary-label" }, RESPONSE_IMG_MIMETYPE), div({ className: "tabpanel-summary-value" }, mimeType) ) ); } } module.exports = ImagePreview; PK