The issue is when you call useEffect for this, this will not happen during initial render phase.
State set -> react realizes it needs to fire an effect -> usEffect runs -> state set again (filteredItems) -> re render
So you see this is not very performant.
While if you use useMemo (or just simply calculate result without memo), react can calculate result during render which is more desirable
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The issue is when you call
useEffect
for this, this will not happen during initial render phase.State set -> react realizes it needs to fire an effect -> usEffect runs -> state set again (
filteredItems
) -> re renderSo you see this is not very performant.
While if you use
useMemo
(or just simply calculate result without memo), react can calculate result during render which is more desirable