исправление ошибки с размонтированием
This commit is contained in:
parent
7101487269
commit
dd15bc0ad1
@ -152,12 +152,17 @@ export default class RecentTorrents extends Component {
|
|||||||
this.torrents = data;
|
this.torrents = data;
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
});
|
});
|
||||||
window.torrentSocket.on('newTorrent', (torrent) => {
|
this.newTorrentFunc = (torrent) => {
|
||||||
this.torrents.unshift(torrent);
|
this.torrents.unshift(torrent);
|
||||||
if(this.torrents.length > 10)
|
if(this.torrents.length > 10)
|
||||||
this.torrents.pop()
|
this.torrents.pop()
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
});
|
};
|
||||||
|
window.torrentSocket.on('newTorrent', this.newTorrentFunc);
|
||||||
|
}
|
||||||
|
componentWillUnmount() {
|
||||||
|
if(this.newTorrentFunc)
|
||||||
|
window.torrentSocket.off('newTorrent', this.newTorrentFunc);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
if(!this.torrents || this.torrents.length == 0)
|
if(!this.torrents || this.torrents.length == 0)
|
||||||
|
@ -46,14 +46,17 @@ export default class Search extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.torrentSocket.emit('statistic', (statistic) => {
|
this.newStatisticFunc = (statistic) => {
|
||||||
this.stats = statistic;
|
this.stats = statistic;
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
});
|
};
|
||||||
window.torrentSocket.on('newStatistic', (statistic) => {
|
window.torrentSocket.emit('statistic', this.newStatisticFunc);
|
||||||
this.stats = statistic;
|
window.torrentSocket.on('newStatistic', this.newStatisticFunc);
|
||||||
this.forceUpdate();
|
}
|
||||||
});
|
componentWillUnmount()
|
||||||
|
{
|
||||||
|
if(this.newStatisticFunc)
|
||||||
|
window.torrentSocket.off('newStatistic', this.newStatisticFunc);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const style = {
|
const style = {
|
||||||
|
Loading…
Reference in New Issue
Block a user