diff --git a/src/App.js b/src/App.js index 1ac195632..f08bfb7f8 100644 --- a/src/App.js +++ b/src/App.js @@ -20,10 +20,16 @@ const App = () => { }, ]; + const [searchTerm, setSearchTerm] = React.useState(''); + const handleSearch = event => { - console.log(event.target.value); + setSearchTerm(event.target.value); }; + const searchedStories = stories.filter(story => + story.title.toLowerCase().includes(searchTerm.toLowerCase()) + ); + return (

My Hacker Stories

@@ -32,30 +38,17 @@ const App = () => {
- +
); }; -const Search = props => { - const [searchTerm, setSearchTerm] = React.useState(''); - - const handleChange = event => { - setSearchTerm(event.target.value); - - props.onSearch(event); - }; - - return ( -
- - -

- Searching for {searchTerm}. -

-
- ); -}; +const Search = props => ( +
+ + +
+); const List = props => props.list.map(item => (