Skip to content

RTK Query: manually reset mutation state #1630

@tkharuk

Description

@tkharuk

I'm facing a situation where I need to hide error from mutation.
In React Query there is a mutation.reset method that would do that.

Are there ways to achieve something similar?

const CreateTodo = () => {
   const [create, { error }] = useCreateMutation()
 
   const onCreateTodo = () => {
     create({ /* ... */ })
   }

   const hideError = () => {
     // mutation.reset() ?
   }
 
   return (
     <form onSubmit={onCreateTodo}>
       {error && <h5 onClick={hideError}>{error}</h5>}

        // ...
       <button type="submit">Create Todo</button>
     </form>
   )
 }

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