Last active
May 13, 2020 23:39
-
-
Save arshmakker/64f5ee80284b58b6d47c195bbaf77ee9 to your computer and use it in GitHub Desktop.
Header.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import Search from './Search' | |
import LogoBar from './LogoBar' | |
import InitialList from './InitialList' | |
import ResultsList from './ResultsList' | |
function Header({ InitialData = new Set(["1st Option", | |
"2nd Option", | |
"3rd Option"]) }) { | |
const [results, setResults] = useState([]) | |
const searchTriggered = keyword => { | |
let valuesFound = []; | |
InitialData.forEach(ele => { | |
if (ele.match(keyword)) { | |
valuesFound.push(ele) | |
} | |
}) | |
setResults(new Set(valuesFound)) | |
} | |
return ( | |
<> | |
<div style={{ | |
display: "flex", margin: "20px", | |
justifyContent: "space-around", | |
background: "lightblue" | |
}}> | |
<LogoBar /> | |
<Search onSearchResults={searchTriggered} /> | |
</div> | |
<div style={{ | |
display: "flex", margin: "20px", | |
justifyContent: "space-around", | |
}}> | |
<div style={{ | |
padding: "20px", | |
background: "lightgrey" | |
}}> | |
<InitialList list={InitialData} /> | |
</div> | |
<div style={{ | |
padding: "20px", | |
background: "lightgreen" | |
}}> | |
<ResultsList list={results} /> | |
</div> | |
</div> | |
</> | |
) | |
} | |
export default Header |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment