useMutation isError state doesn't change when there is no internet connection #3334
-
Hello, so I noticed there is no state change when a mutation request is made while being disconnected from the internet. The isLoading state becomes true and perpetually remains that way . I expect the mutation to fail with no internet connection and hence update the isError state to true and turn isLoading to false. Please can anyone help with how I can solve this issue, I want to be able to give feedback to the user when there is a problem with their internet connection. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
have you turned on retries for mutations? Because without retries (the default), offline mutations would just error as you'd expect. With retries, mutations will be paused and the However, please keep in mind that better offline support if our flagship feature for v4, which is currently in alpha. You can read about it here:
|
Beta Was this translation helpful? Give feedback.
-
This seems to be a problem for the latest react-query version. Screen.Recording.2022-10-21.at.12.55.28.movhttps://codesandbox.io/s/usemutation-demo-forked-pedp9k?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
-
export const useApiGetQuery = ({ key, endpoint, params, options = {} }) => { |
Beta Was this translation helpful? Give feedback.
have you turned on retries for mutations? Because without retries (the default), offline mutations would just error as you'd expect.
With retries, mutations will be paused and the
isPaused
flag will be set to true. mutations will then resume automatically once you have regained internet connection.However, please keep in mind that better offline support if our flagship feature for v4, which is currently in alpha. You can read about it here: