Skip to content

mutation function useCallback is always regenerated  #165

@owinter86

Description

@owinter86

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 
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions