From 074e002e7d25e4ea8a9d06a259826ca4dc152872 Mon Sep 17 00:00:00 2001 From: Ken Jannette Date: Thu, 19 Apr 2018 15:56:02 -0400 Subject: [PATCH] Started search functionality --- src/App.js | 13 +++++++++++-- src/SearchPage.js | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 4e2967c..745a9b2 100755 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,7 @@ import React from 'react' import { BrowserRouter, Link, Route } from 'react-router-dom' // import * as BooksAPI from './BooksAPI' import Bookshelf from './Bookshelf' -import { getAll } from './BooksAPI' +import { getAll, search } from './BooksAPI' import SearchPage from './SearchPage' import './App.css' @@ -33,6 +33,13 @@ class BooksApp extends React.Component { this.setState({ books }); } + onSearch = (query) => { + if (query.length > 3) { + search(query).then((result) => + console.log(result)) + } + } + render() { return ( @@ -47,7 +54,9 @@ class BooksApp extends React.Component { )}/> ( - + )}/>
diff --git a/src/SearchPage.js b/src/SearchPage.js index 2f079a2..5ca64c4 100644 --- a/src/SearchPage.js +++ b/src/SearchPage.js @@ -2,7 +2,11 @@ import React, { Component } from 'react'; import { Link } from 'react-router-dom' class SearchPage extends Component { + render() { + + const onSearch = this.props.onSearch + return (
@@ -11,6 +15,7 @@ class SearchPage extends Component { onSearch(e.target.value)} />