-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
RTKQ: Query is unsubscribed immediately after mounting in React 18 StrictMode #1838
Comments
I see this was already discussed at reduxjs/react-redux#1732 My bad. Tried react-redux v8 beta. Seems to work. At least problem 2 does not happen. Problem 1 still happens. But I guess it is a React behavior and nothing to do here. Issue can be closed as far as I am concerned. |
Yeah, the extra unmount is part of the new "Strict Effects" behavior as far as I know. |
@markerikson what does that do? |
@phryneas It is explained here: reactwg/react-18#19
I just learned about it. |
Interesting and kinda weird. Good to know, thanks! |
I was doing some exploration in React 18 RC and noticed that RTK Query was causing endless loading screens in StrictMode only. I don't know if React 18 is supported yet, but thought this might be helpful.
This is how actions look in React 17 and non strict mode:
This is how it looks in React 18 StrictMode:
Two problems here.
useEffect
cleanup is called for no reason as if component is unmounted, even when the component is not unmounted. That causes RTKQ to unsubscribe.Version: 1.7.1
Sandbox link
The text was updated successfully, but these errors were encountered: