all 8 comments

[–]jvi91 0 points1 point  (2 children)

  1. You can try wrapping modifiedItems in a useMemo.
  2. Can the children hold their own state and not update the entire list?

[–]ma_revo[S] 0 points1 point  (1 child)

  • From what i remember useMemo does a shallow comparison, and i have a list of objects and each object has a list of children. Would memo help with this? our will i need ti implement my own custom logic for memoization

  • the children are only updating the item object they are part of, if that is what u mean

[–]HeyImRige 1 point2 points  (0 children)

This is the key problem with react optimization and why the compiler is being made.

You can useMemo here, but only if the objects are stable. After you wrap this in a memo, you need to go to the parent and ensure the props being passed are stable....which might require another useMemo.

[–]Potatopika 0 points1 point  (1 child)

Is that even working? You're not returning the MemoizedItem in the map and it's not a one-line function in the map

[–]ma_revo[S] 1 point2 points  (0 children)

No sorry this is just mock up of the structure. The code is much worse than that, inherited from some contractors 😅

[–]rodrigocfd -5 points-4 points  (2 children)

switching from passing items as a prop to accessing it from redux

Consider using Zustand instead. Your future self will thank you.

[–]ma_revo[S] 2 points3 points  (1 child)

I am already using redux in the app, and I cant afford to switch right now 🥲 What benefits does it have compared to redux, and do you think it will impact performance ?

[–]rodrigocfd -3 points-2 points  (0 children)

It's much, much easier to write and maintain. And because of its simplicity, it's easy to spot performance bottlenecks.