Editing SearchPage to fix bug(s)
This commit is contained in:
@@ -4,13 +4,18 @@ import { search } from './BooksAPI'
|
|||||||
|
|
||||||
class SearchPage extends Component {
|
class SearchPage extends Component {
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
super();
|
||||||
|
this.results = ''
|
||||||
|
}
|
||||||
|
|
||||||
onSearch = (query) => {
|
onSearch = (query) => {
|
||||||
if (query.length > 3) {
|
if (query.length > 3) {
|
||||||
search(query).then((results) => {
|
search(query).then((searchResults) => {
|
||||||
this.results = results
|
this.results = searchResults
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
@@ -26,14 +31,14 @@ class SearchPage extends Component {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search by title or author"
|
placeholder="Search by title or author"
|
||||||
onChange={e => onSearch(e.target.value)}
|
onChange={e => this.onSearch(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="search-books-results">
|
<div className="search-books-results">
|
||||||
<ol className="books-grid">
|
<ol className="books-grid">
|
||||||
|
|
||||||
{results.map((result) =>
|
{this.results.map((result) =>
|
||||||
|
|
||||||
<li key={result.id}>
|
<li key={result.id}>
|
||||||
<div className="book">
|
<div className="book">
|
||||||
|
|||||||
Reference in New Issue
Block a user