-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
46 lines (40 loc) · 1.64 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { useState, useRef } from 'react';
import Search from './components/icons/Search';
import Popcorn from './components/icons/Popcorn';
import SearchResults from './components/search-results/SearchResults';
import { ConfigurationContextProvider } from './hooks/useConfiguration';
import { SearchContextProvider } from './hooks/useSearch';
function App() {
const inputRef = useRef();
const [query, setQuery] = useState(null);
const handleFormSubmit = event => {
event.preventDefault();
setQuery(inputRef.current.value);
};
return (
<ConfigurationContextProvider>
<SearchContextProvider>
<div className="app">
<header>
<Popcorn className="header-logo" />
<button className="header-link">Favorites</button>
<button className="header-link">Watchlist</button>
<form
className="header-search"
onSubmit={handleFormSubmit}
>
<Search className="header-search-icon" />
<input
className="header-search-input"
placeholder="Search"
ref={inputRef}
></input>
</form>
</header>
<main>{query && <SearchResults query={query} />}</main>
</div>
</SearchContextProvider>
</ConfigurationContextProvider>
);
}
export default App;