Skip to content
New issue

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

add reset method to useMutation hook #1476

Merged
merged 6 commits into from
Oct 1, 2021
Merged

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Sep 3, 2021

This would resolve #1455.

Also, it eliminiates all useRef usages in the useMutation hook, which is probably not a bad thing.

@netlify
Copy link

netlify bot commented Sep 3, 2021

✔️ Deploy Preview for redux-starter-kit-docs ready!

🔨 Explore the source changes: 6d09682

🔍 Inspect the deploy log: https://app.netlify.com/sites/redux-starter-kit-docs/deploys/6144ef096362f000071c68e3

😎 Browse the preview: https://deploy-preview-1476--redux-starter-kit-docs.netlify.app

@github-actions
Copy link

github-actions bot commented Sep 3, 2021

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit (cjs.production.min.js) 12.28 KB (0%)
1. entry point: @reduxjs/toolkit (esm.js) 10.27 KB (0%)
1. entry point: @reduxjs/toolkit/query (cjs.production.min.js) 20.42 KB (+0.07% 🔺)
1. entry point: @reduxjs/toolkit/query (esm.js) 17.43 KB (+0.11% 🔺)
1. entry point: @reduxjs/toolkit/query/react (cjs.production.min.js) 22.44 KB (+0.09% 🔺)
1. entry point: @reduxjs/toolkit/query/react (esm.js) 20 KB (+0.05% 🔺)
2. entry point: @reduxjs/toolkit (without dependencies) (cjs.production.min.js) 5.6 KB (0%)
2. entry point: @reduxjs/toolkit (without dependencies) (esm.js) 5.58 KB (0%)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs.production.min.js) 9.22 KB (+0.16% 🔺)
2. entry point: @reduxjs/toolkit/query (without dependencies) (esm.js) 9.6 KB (+0.18% 🔺)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (cjs.production.min.js) 2.52 KB (-0.16% 🔽)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (esm.js) 2.35 KB (-0.29% 🔽)
3. createSlice (esm.js) 5.16 KB (0%)
3. createEntityAdapter (esm.js) 5.83 KB (0%)
3. configureStore (esm.js) 5.83 KB (0%)
3. createApi (esm.js) 15.74 KB (+0.12% 🔺)
3. createApi (react) (esm.js) 18.25 KB (+0.1% 🔺)
3. fetchBaseQuery (esm.js) 10.98 KB (0%)
3. setupListeners (esm.js) 9.86 KB (0%)
3. ApiProvider (esm.js) 17.16 KB (+0.1% 🔺)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 3, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6d09682:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration

@taejs
Copy link
Contributor

taejs commented Sep 9, 2021

Is there no need to update query results using same tags?

@phryneas
Copy link
Member Author

phryneas commented Sep 9, 2021

@taejs after just clearing a mutation result? That does not mean the mutation has run again or anything was sent to the server, it just means the component does not want to display the result anymore

@LhonRafaat
Copy link

LhonRafaat commented Sep 12, 2021

when is this gonna be available? @phryneas

@phryneas
Copy link
Member Author

@LhonRafaat next minor release. Could still be a month or two, given what else we want in there. In the meantime you can either use the CodeSandbox build linked above or do something like

const lastMutation = useRef(undefined)
const [trigger] = useMyMutation()


// when triggering:
lastMutation.current = trigger(arg);


// to reset
lastMuation.current.unsubscribe()

@Shrugsy
Copy link
Collaborator

Shrugsy commented Sep 18, 2021

@phryneas the spelling & wording threads are still open, but besides that, LGTM!

@phryneas phryneas modified the milestones: 1.8, 1.7 Oct 1, 2021
@phryneas phryneas changed the base branch from master to v1.7.0-integration October 1, 2021 10:20
@phryneas phryneas merged commit b5ed969 into v1.7.0-integration Oct 1, 2021
@phryneas phryneas deleted the pr/reset-mutations branch October 1, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Feature Request: Callback to Reset Mutation Status
6 participants