-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove redundant isMounted
ref from connect
#1941
Conversation
@@ -622,18 +621,9 @@ function connect< | |||
const lastWrapperProps = useRef(wrapperProps) | |||
const childPropsFromStoreUpdate = useRef<unknown>() | |||
const renderIsScheduled = useRef(false) | |||
const isProcessingDispatch = useRef(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is a bonus removal - this ref stayed completely unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current-me has no clue what past-me was thinking for this variable :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such is the live of a developer. What's comforting is that Future You thinks Present You is a moron, too. 🤣
Of course this is a good thing. We want Future Us to be smarter than Present Us. 📈
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3cc4a80:
|
AHHHH that makes sense! |
I guess the fix is not fully correct since tests fail 🤣 but nevertheless I think that it would fix the mentioned issue. It would be interesting to understand how the subscription nesting works and how it depends on this |
So basically with this change, we have 2 affected tests:
The first one fails because So what's the problem? The problem here is that Interestingly, I went back in time to check out something and in 7.x this react-redux/src/components/connectAdvanced.js Lines 417 to 419 in fee8190
I've noticed one additional thing in the current implementation: react-redux/src/components/connect.tsx Lines 161 to 163 in 720f0ba
Perhaps if this could be refactored to get more "inline" with the intended usage the problem would go away. I assume that in such a case React's implementation wouldn't rerender this component at all as it was already unmounted in its internal data structures and |
Yeah, the reason for all that "non-standard" usage of I couldn't come up with a good way to break apart that logic, so I ended up with an implementation where |
After further investigation, I've concluded this is actually a bug in the See #1940 for discussion. Thanks for the attempted fix! |
Most likely this should fix #1940 . It would be cool if @markerikson or @bvaughn could test this out using the parent of this commit in Replay: replayio/devtools@477dd47