/* * OpenBills - Self hosted browser app to generate and keep track of simple invoices * Version - 0 * Licensed under the MIT license - https://opensource.org/licenses/MIT * * Copyright (c) 2021 Vidhu Kant Sharma */ import React, { useState } from "react"; import "./SearchBar.scss"; const SearchBar: React.FC = () => { const sampledata: string[] = ["one", "two", "three", "four", "five", "six"] const [searchValue, setSearchValue] = useState(""); const [searchSelection, setSearchSelection] = useState(""); const setSelectionValue = (value: string) => { setSearchValue(""); setSearchSelection(value); console.log(searchSelection); } return (
{ setSearchValue(event.target.value); console.log(searchSelection); } } />
{ searchValue === "" || sampledata.map((i) => i.toLowerCase().includes(searchValue.toLowerCase()) && (

setSelectionValue(i)}>{i}

)) }
); } export default SearchBar;