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 the wrapped component dispatches any action in cDU or uLE as a reaction to external prop change, an unnecessary re-render is made
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:
Child re-renders only once after clicking the button
Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
@ckedar : no, we should not modify refs while rendering. That should only ever be doing in the commit phase, once we know the component has finished rendering.
I'm going to close this as a WONTFIX for now, largely because we're encouraging folks to stop using connect (even though it'll be fully supported in v8).
If someone still feels strongly about this please comment, or even better file a PR to improve behavior here.
Do you want to request a feature or report a bug?
A bug
What is the current behavior?
When the wrapped component dispatches any action in
cDU
oruLE
as a reaction to external prop change, an unnecessary re-render is madeIf the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:
https://codesandbox.io/s/unruffled-glitter-ofxmq?fontsize=14
Open console, click "Activate"
What is the expected behavior?
Child
re-renders only once after clicking the buttonWhich versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
See codesandbox above
The probable reason of the bug is that
lastWrapperProps.current
is outdated at the moment of dispatch:https://github.com/reduxjs/react-redux/blob/master/src/components/connectAdvanced.js#L322-L325
This leads to
ownProps
reference being reset to an older value:https://github.com/reduxjs/react-redux/blob/master/src/connect/selectorFactory.js#L78
One possible workaround is to introduce a separate
recentWrapperProps
ref and set in immediately insiderender
The text was updated successfully, but these errors were encountered: