React immutability performance
Hi! Is it possible to avoid calling
renderPosts
every time when filteredPosts
gets mutated?
filteredPosts
is mutated because state search
value changes, but actually the value of filteredPosts
(array of objects) did not (in case the search expression is not too specific)
Can I handle this mutability in React?
1 Reply
forgive me if im wrong, but i think renderPosts() shouldnt be called just because filteredPosts is recalculated
it should just recreate the function, but not run it
if the function is running again, its probably because your rendered components are getting re-rendered and then that is calling renderPosts()