Our usage of useSelector, or in our case useAppSelector, uses the entire state object. This is non performant and highly discouraged.
A warning is generated in new versions of react-redux:
Selector unknown returned the root state when called. This can lead to unnecessary rerenders.
Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.
Benefits
More performant usage of react-redux and no more warnings.
Possible Solution and Impacts
Update our usage and any related tests
Tests will require rework where they rely upon spy/mock of useAppSelector
In GitLab by @tom.downes on Feb 28, 2024, 09:16
Summary
Our usage of
useSelector
, or in our caseuseAppSelector
, uses the entire state object. This is non performant and highly discouraged.A warning is generated in new versions of
react-redux
:Benefits
More performant usage of
react-redux
and no more warnings.Possible Solution and Impacts
useAppSelector
Are all areas of the checklist addressed?