[RTKQ] When using selectFromResult even focus triggers a component re-render #1716
-
I'm trying to use the const plannersData = useGetAllPlannersQuery(
{ businessUnitCode },
{
selectFromResult: ({ data }) =>
data && data.map((it) => ({ value: it.id, label: it.name })),
},
); However I've noticed that my component is re-rendering a LOT, even when the page simply gets focused. Just commenting out the Redux Toolkit version: 1.6.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are creating a new object on each render - they will always be "different object" and have the same problem as doing the same thing in a normal Redux selector. At that point you will need to use a memoized selector for that. |
Beta Was this translation helpful? Give feedback.
You are creating a new object on each render - they will always be "different object" and have the same problem as doing the same thing in a normal Redux selector. At that point you will need to use a memoized selector for that.