query icon indicating copy to clipboard operation
query copied to clipboard

mutation function useCallback is always regenerated

Open oliverwinter-vdb opened this issue 6 years ago • 1 comments

https://github.com/tannerlinsley/react-query/blob/a76d1dfdc0a6d13ace169ce46ad8aef868ed4dd7/src/useMutation.js#L68-L99

Since the state.status will always change when the mutate function fires, the memoisation of useCallback fails and can cause runaway effects if the mutate function is passed in the dependency array of a useEffect.

if this check needed for anything in particular?

if (![statusIdle, statusSuccess, statusError].includes(state.status)) { 
  return 
} 

oliverwinter-vdb avatar Feb 27 '20 20:02 oliverwinter-vdb

Closed with #166

tannerlinsley avatar Feb 27 '20 20:02 tannerlinsley