отображение результатов поиска
This commit is contained in:
parent
1b6a15bcdd
commit
2b861167cd
23
src/search-results.js
Normal file
23
src/search-results.js
Normal file
@ -0,0 +1,23 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
export default class SearchResults extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="column">
|
||||
{
|
||||
this.props.results && this.props.results.length > 0
|
||||
?
|
||||
this.props.results.map((torrent, index) => {
|
||||
return (
|
||||
<div key={index}>
|
||||
{torrent.name}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
@ -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 (
|
||||
<div className="row">
|
||||
<input type='text' ref='searchInput' onKeyPress={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
window.torrentSocket.emit('search', e.target.value, (torrents) => {
|
||||
console.log(torrents);
|
||||
});
|
||||
}
|
||||
}} />
|
||||
<div className="column">
|
||||
<div className='row'>
|
||||
<input type='text' ref='searchInput' onKeyPress={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
window.torrentSocket.emit('search', e.target.value, (torrents) => {
|
||||
this.searchData = torrents;
|
||||
this.forceUpdate();
|
||||
});
|
||||
}
|
||||
}} />
|
||||
</div>
|
||||
<SearchResults results={this.searchData} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user