79810009

Date: 2025-11-05 12:10:28
Score: 5.5
Natty:
Report link

@Drew - At first - I really want to optimize number of renders, not commits. I have supplied the state mutation function in the post, but again - this is more an academical question. Redux allows you to create selectors to re-render only on change of any specified leave of the redux state tree (using createSelector + useSelector). I am trying to accomplish something similar within my own library. Without depending on Redux. Problem is not in my code, problem is in how the context works and that it does not support such behaviour by default. I want to re-render my component only when a specific item is added or removed from the list stored in useState. I will create a simple MRE today, give me a moment.

Reasons:
  • Blacklisted phrase (1): I am trying to
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • No code block (0.5):
  • User mentioned (1): @Drew
  • Self-answer (0.5):
  • Single line (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: Wax Cage