We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
mutation.reset
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> ) }
The text was updated successfully, but these errors were encountered:
For usage questions, please use the discussions section rather than issues.
A reset method will be available in v1.7 which is not released yet.
reset
In the meantime, @phryneas has shown how you can imitate the functionality yourself in this comment.
e.g.
const CreateTodo = () => { const lastMutation = useRef(undefined) const [create, { error }] = useCreateMutation() const onCreateTodo = () => { lastMutation.current = create({ /* ... */ }) } const hideError = () => { lastMutation.current?.unsubscribe() } return ( <form onSubmit={onCreateTodo}> {error && <h5 onClick={hideError}>{error}</h5>} // ... <button type="submit">Create Todo</button> </form> ) }
Sorry, something went wrong.
@Shrugsy thanks for links!
No branches or pull requests
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?
The text was updated successfully, but these errors were encountered: