Replies: 1 comment 5 replies
-
It sounds like you're kicking off navigations in renders or effects which could cause them to navigate twice which would run loaders twice. Instead, you should be navigating via link clicks (which will only fire once) or if you need to redirect, do that from a loader as well instead of a |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've just tried converting my app to use a Loader instead of a wrapper component with
useEffect
. And, in general, it works fine. However, the loader is running twice under strict mode where it wasn't before.In general this is ok. However, in my case it's a problem. The loader is handling the callback from authentication, so it's going and making the XHR call to obtain an access token. And this call only ever works once - after which the authorization code is used and subsequent calls fail. So, when my loader runs twice, one of them will succeed and the other will fail.
Note that this is not a problem if I remove StrictMode, or if I run under production settings, then this problem goes away because the double-render that StrictMode does also goes away.
So, is there some way to ensure that the loader only runs once and not twice under this condition?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions