базовый клиент на сайте

This commit is contained in:
Alexey Kasyanchuk
2017-01-01 05:56:09 +03:00
parent d8928b8eb4
commit 46708c8f7e
26 changed files with 3331 additions and 17 deletions

35
src/recent-torrents.js Normal file
View File

@ -0,0 +1,35 @@
import React, { Component } from 'react';
export default class RecentTorrents extends Component {
constructor() {
super()
this.torrents = [];
}
componentDidMount() {
window.torrentSocket.emit('recentTorrents', (data) => {
this.torrents = data;
this.forceUpdate();
});
window.torrentSocket.on('newTorrent', (torrent) => {
this.torrents.unshift(torrent);
if(this.torrents.length > 10)
this.torrents.pop()
this.forceUpdate();
});
}
render() {
return (
<div className="list column">
{
this.torrents.map((torrent, index) =>{
return(
<div key={index}>
{torrent.name}
</div>
);
})
}
</div>
);
}
}