Merge pull request #127 from lbryio/development

Merge development into master
This commit is contained in:
alexliebowitz 2017-01-04 17:09:01 -05:00 committed by GitHub
commit 15d9236500
2 changed files with 7 additions and 2 deletions

View file

@ -120,6 +120,7 @@ export let Address = React.createClass({
export let Thumbnail = React.createClass({ export let Thumbnail = React.createClass({
_defaultImageUri: '/img/default-thumb.svg', _defaultImageUri: '/img/default-thumb.svg',
_maxLoadTime: 10000, _maxLoadTime: 10000,
_isMounted: false,
propTypes: { propTypes: {
src: React.PropTypes.string.isRequired, src: React.PropTypes.string.isRequired,
@ -137,14 +138,18 @@ export let Thumbnail = React.createClass({
}; };
}, },
componentDidMount: function() { componentDidMount: function() {
this._isMounted = true;
setTimeout(() => { setTimeout(() => {
if (!this.refs.img.complete) { if (this._isMounted && !this.refs.img.complete) {
this.setState({ this.setState({
imageUri: this._defaultImageUri, imageUri: this._defaultImageUri,
}); });
} }
}, this._maxLoadTime); }, this._maxLoadTime);
}, },
componentWillUnmount: function() {
this._isMounted = false;
},
render: function() { render: function() {
return <img ref="img" onError={this.handleError} {... this.props} src={this.state.imageUri} /> return <img ref="img" onError={this.handleError} {... this.props} src={this.state.imageUri} />
}, },

View file

@ -292,7 +292,7 @@ var DiscoverPage = React.createClass({
document.title = "Discover"; document.title = "Discover";
if (this.props.query) { if (this.props.query) {
// Rendering with a query already typed // Rendering with a query already typed
this.handleSearchChanged(); this.handleSearchChanged(this.props.query);
} }
}, },