You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the useSelector hook, a console warning is shown instructing the user to memoize the result.
Since getFlashMessages returns new array, it will always trigger a re-render of its component (the default comparator is shallow equals, i.e., ===).
This is especially worrisome because it's usually included in the top Layout component within our client repos and will trigger a re-render after every action is handled and updates state somewhere in the tree, which could have a cascading effect on triggering child re-renders throughout the app.
Potential solutions:
Don't export selectors
Use createSelector from reselect to memoize the selectors
The text was updated successfully, but these errors were encountered:
When using the
useSelector
hook, a console warning is shown instructing the user to memoize the result.Since
getFlashMessages
returns new array, it will always trigger a re-render of its component (the default comparator is shallow equals, i.e.,===
).This is especially worrisome because it's usually included in the top
Layout
component within our client repos and will trigger a re-render after every action is handled and updates state somewhere in the tree, which could have a cascading effect on triggering child re-renders throughout the app.Potential solutions:
createSelector
fromreselect
to memoize the selectorsThe text was updated successfully, but these errors were encountered: