Skip to content

How can I avoid renders using updateOne from createEntityAdapter #1229

Answered by markerikson
Agmat asked this question in Q&A
Discussion options

You must be logged in to vote

This is normal behavior for immutable updates.

An immutable update requires that every level of nesting that you are trying to update has to be copied. So, if I want to update state.todos.entities["abcd"].completed, it has to copy:

  • the {id: "abcd"} entity object
  • entities
  • todos
  • state

So, yes, if you are trying to select state.someSlice.entities, that will be a new reference every time you apply an update. That means that the component will re-render, and if you're using that as an effect dependency, the effect will run too.

What are you trying to accomplish in that effect?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Agmat
Comment options

@markerikson
Comment options

@Agmat
Comment options

Answer selected by Agmat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants