fix crash on image with no data

This commit is contained in:
or-else
2022-01-12 17:27:39 -08:00
parent 479752036d
commit e87a36421c
8 changed files with 58 additions and 26 deletions
+1
View File
@@ -31,6 +31,7 @@ export default class LazyImage extends React.PureComponent {
if (prevProps.whenDone != this.props.whenDone) {
this.setState({src: 'img/placeholder.png', style: {...this.state.style, padding: '4px'}});
this.props.whenDone
.promise
.then(data => this.setState({src: data.src, style: {...this.state.style, padding: 0}}))
.catch(() => this.setState({src: 'img/broken_image.png'}));
}