From 2b861167cd7346deeb1a2e53acbee415013788f7 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sun, 1 Jan 2017 06:40:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D0=BE=D0=B2=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/search-results.js | 23 +++++++++++++++++++++++ src/search.js | 25 ++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 src/search-results.js diff --git a/src/search-results.js b/src/search-results.js new file mode 100644 index 0000000..f698750 --- /dev/null +++ b/src/search-results.js @@ -0,0 +1,23 @@ +import React, { Component } from 'react'; + +export default class SearchResults extends Component { + render() { + return ( +
+ { + this.props.results && this.props.results.length > 0 + ? + this.props.results.map((torrent, index) => { + return ( +
+ {torrent.name} +
+ ); + }) + : + null + } +
+ ); + } +} diff --git a/src/search.js b/src/search.js index b6e099b..252b86f 100644 --- a/src/search.js +++ b/src/search.js @@ -1,19 +1,22 @@ import React, { Component } from 'react'; -export default class Search extends Component { - componentDidMount() { +import SearchResults from './search-results' - } +export default class Search extends Component { render() { return ( -
- { - if (e.key === 'Enter') { - window.torrentSocket.emit('search', e.target.value, (torrents) => { - console.log(torrents); - }); - } - }} /> +
+
+ { + if (e.key === 'Enter') { + window.torrentSocket.emit('search', e.target.value, (torrents) => { + this.searchData = torrents; + this.forceUpdate(); + }); + } + }} /> +
+
); }