Replies: 1 comment 1 reply
-
your selectors should return a stable reference, because a new reference is treated as a change in state. if your selector returned a new array instance every time it was called, you would get unnecessary rerenders. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I ask about the use of
emptyUsers: User[] = []
from https://redux.js.org/tutorials/essentials/part-8-rtk-query-advanced#selecting-users-dataFor context, my team believes that the docs suggest the practice (of the
emptyEntity: Entity[] = []
as part of a performance bit to avoid re-rendering (or any other improvements on performance). I (on the other hand) am convinced that it's just a semantic way to say "this empty array represents an empty list of users" plus it helps documentation (no performance effect in the middle), which to me also means, I could remove that variable and send the empty array directly (instead of creating/casting a value for it).I know, it may sound silly but I would like some some input on this.
Beta Was this translation helpful? Give feedback.
All reactions