Answer the question
In order to leave comments, you need to log in
Why does useSelector return different objects?
Good afternoon, I can not figure out the problem and understand what's wrong.
Returns a "new" object each time and re-renders.
state.dashboard does not change (other parts of the store change, reducers are clean, everything is as it should be) in redux devtool it is clear that the dashboard does not change,
Dashboard in state has an interface:
useSelector(state => state.dashboard);
interface DashboardState {
from: Date;
to: Date;
}
shallowEqual
, then everything is fine and works as it should, no re-renders const from = useSelector(state => state.dashboard.from);
const to = useSelector(state => state.dashboard.to);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question