This is really weird and my instructor is confused as well. I copied some code from my classmate — it worked fine on his computer. But it doesn’t work on mine.
The issue is with a search filter.
onChange={(e) => {
if(!e.target.value) return setTransactions(allTrans)
console.log(e.target.value)
let search = transactions.filter((element) => {
return element.description.includes(e.target.value)
})
if (search.length>0) setTransactions(search)
}}
the stateful variable “transactions” is used here:
{transactions.map((transaction) => {
return <Transaction key={transaction.id} transaction={transaction}/>
})}
We figured out the issue is in the rerender. My instructor deleted this code and pasted it back in and that FIXED IT. But then it got messed up again when I edited something else (in a different file). And now I can’t fixed it.
What would be the reason identical React code works on my classmate’s computer but not mine?