Replies: 1 comment 1 reply
-
React 18 runs side effects twice in development which is probably what you're encountering. You can disable react strictmode to stop this behavior. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Built a react app with no client-side requests caching and noticed that the fetchers are doing multiple calls to loaders.
In one instance, I'm using
<fetcher.Form method="post">
, which calls all the loaders of the page again after the submission of the form. Looking athandleFetcherAction()
, it seems intended. I guess it's to ensure the page state is in sync with the mutations of thepost/action
?The other instance is similar to the
useFetcher
docs:Basically,
fetcher.load()
is being called multiple times becausefetcher.state === "idle"
even after.load()
has been called, so it ends up being called twice. I'm not sure why this would be intended, other for optimization. Is this intended?I like the overall design of react router. If the behaviour is staying the same, I feel like this should be in the docs at least.
Edit: Related to the
useEffect()
call, seems likeinvokeEffectsInDev()
is making the second call (see facebook/react#19523). However,useRef
does not work, as the data won't load in my component, while the simple implementation using awindow.fetch()
works.Beta Was this translation helpful? Give feedback.
All reactions