Merge branch 'next' into features
This commit is contained in:
@@ -16,11 +16,17 @@ export default class LazyImage extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// whenDone is a wrapper around an actual promise to be able to cancel it.
|
||||
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'}));
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.whenDone.cancel();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.whenDone != this.props.whenDone) {
|
||||
this.setState({src: 'img/placeholder.png', style: {...this.state.style, padding: '4px'}});
|
||||
|
||||
Reference in New Issue
Block a user