diff --git a/src/SearchPage.js b/src/SearchPage.js index 1eea695..82c065c 100644 --- a/src/SearchPage.js +++ b/src/SearchPage.js @@ -4,13 +4,18 @@ import { search } from './BooksAPI' class SearchPage extends Component { + constructor(){ + super(); + this.results = '' + } + onSearch = (query) => { if (query.length > 3) { - search(query).then((results) => { - this.results = results - }) - } -} + search(query).then((searchResults) => { + this.results = searchResults + }) + } + }; render() { @@ -26,14 +31,14 @@ class SearchPage extends Component { onSearch(e.target.value)} + onChange={e => this.onSearch(e.target.value)} />
    - {results.map((result) => + {this.results.map((result) =>