How to search for anything from an array of objects,?
const [searchInput, setSearchInput] = useState('');
let cars = [
{
"color": "purple",
"type": "minivan",
"registration": new Date('2017-01-03'),
"capacity": 7
},
{
"color": "red",
"type": "station wagon",
"registration": new Date('2018-03-03'),
"capacity": 5
},
]
return (
<>
<input type="text" onChange={(e) =>setSearchInput(e.target.value)}
{
cars?.filter(x => Object.values(x).includes(searchInput.toLowerCase())).map((d) =>{
console.log(d) // nothing is consoled from here tu
//show the data here but nothing is showing here
})
}
</>
)
No errors but the data are not showing whatsoever, what is wrong here?