Skip to content

Instantly share code, notes, and snippets.

@arshmakker
Last active May 13, 2020 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arshmakker/64f5ee80284b58b6d47c195bbaf77ee9 to your computer and use it in GitHub Desktop.
Save arshmakker/64f5ee80284b58b6d47c195bbaf77ee9 to your computer and use it in GitHub Desktop.
Header.jsx
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