diff --git a/src/views/List.jsx b/src/views/List.jsx index 60ab492..14ba1bd 100644 --- a/src/views/List.jsx +++ b/src/views/List.jsx @@ -1,14 +1,44 @@ import { ListItem } from '../components'; +import { useState, useEffect } from 'react'; export function List({ data }) { + const [filterVal, setFilterVal] = useState(''); + const [filteredList, setFilteredList] = useState([]); + + const clearInput = (e) => { + e.preventDefault(); + setFilterVal(''); + }; + + useEffect(() => { + setFilteredList( + data.filter((item) => + item.name.toLowerCase().includes(filterVal.toLowerCase()), + ), + ); + }, [filterVal, data]); + return ( <>

Hello from the /list page!

+ +
+ + setFilterVal(e.target.value)} + /> + {filterVal && } +
+