Skip to content

Passing regular non-memoized selector to useStore causes infinite re-renders #3155

Answered by dai-shi
ansavchenco asked this question in Bug report
Discussion options

You must be logged in to vote

Try this:

-   const store = useStore((state) =>
+   const store = useStore(useShallow((state) =>
      state.orderedIds.map((id) => state.itemsById[id])
-   );
+   ));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ansavchenco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants