import { useState } from 'react' import './App.css' function App() { return ( <> ) } const produts:string[] = ['mouse', 'pad'] interface Product { name: string, price: number } const productsss:Product[]=[ {name:'mobile', price: 2000}, {name:'laptop', price:30000} ] function ProductsTable(){ return (
{ productsss.map(product=> ) }
) } function ProductTableRows({name, price}:{name:string, price:number}){ return (
Name Price
{name} {price}
) } function SimpleSearch(){ const [searchedMatched, setSearchedMatch] = useState([]) function handleSearch(searchedItem:string):void{ let newMatched = productsss.find(p=>{ if (p.name===searchedItem) { return p.name } }) let reNewMatched = [...searchedMatched, newMatched] setSearchedMatch(reNewMatched) // if (produts.includes(searchedItem)){ // let newMatched = [...searchedMatched,searchedItem] // setSearchedMatch(newMatched) // } } return (
handleSearch(e.target.value)}/> { searchedMatched.map(product=>
  • {product}
  • ) }
    ) } export default App