Hi guys I was stuck on a problem with state being behind a click. I'm creating an input where users can type the name of the item they want and the handleChange function would filter the original items array for titles that match whatever is in the input value. I searched up a couple stack overflow questions that were similar to this problem and they suggested console.logging in useEffects but when I do that, it's still one click behind. Any suggestions?
the functionality:
const handleChange = (e) => {
const results = []
setValue(e.target.value)
for (let item of items) {
if (item.includes(value)) {
results.push(item)
}
}
setNewItems(results)
}
useEffect(() => {
console.log(newItems)
}, [newItems])
the component:
<input
onChange={handleChange}
value={value}
/>