-
I found this previous discussion: I don't think it does. mutations have side-effects on the server, they are not idempotent, so we cannot do as many optimization as with "pure" GET requests. Originally posted by @TkDodo in #608 (reply in thread) Use case: a request sending a refresh token stored in a secure httpOnly cookie - where the server employs re-use detection - should only be sent once, and the request returns new auth state. I have a PersistLogin wrapper component that sends this request when a user wants to persist their login and has lost their state due to refreshing or navigating away and returning. Before React 18, useEffect triggered this request once with no issues. I'm now applying a useRef fix to avoid the double call in strict mode. Maybe I need to stick with useRef but I'm wondering if it would be possible for React Query to look further into mutation deduplication. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I still think this is out of scope for react-query; the issue seems to be react firing effects twice in strict mode (only for dev builds), so the workarounds are either to ignore it (because it has not production impact) or to work around it with the ref. |
Beta Was this translation helpful? Give feedback.
I still think this is out of scope for react-query; the issue seems to be react firing effects twice in strict mode (only for dev builds), so the workarounds are either to ignore it (because it has not production impact) or to work around it with the ref.