-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Modify onMutate signature to add context parameter #9982
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
base: main
Are you sure you want to change the base?
Conversation
Updated the onMutate function signature to include context.
|
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/framework/react/reference/useMutation.md (1)
67-71: Update description to match the signature change.The
onMutatesignature has been updated to include thecontextparameter, but the description on line 69 only mentions that it receives "variables" and doesn't reflect the newcontextparameter being passed. This creates a mismatch between the signature and its documentation.Align the description with the updated signature to clarify that
onMutatereceives bothvariablesandcontext.🔎 Proposed fix for the description
- `onMutate: (variables: TVariables, context: MutationFunctionContext) => Promise<TOnMutateResult | void> | TOnMutateResult | void` - Optional - - This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive + - This function will fire before the mutation function is fired and is passed the same variables and context the mutation function would receive - Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/framework/react/reference/useMutation.md(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Agent
🔇 Additional comments (1)
docs/framework/react/reference/useMutation.md (1)
51-51: Consistency across callback signatures is good.The
onMutatesignature update aligns well with the other callback signatures (mutationFn,onSuccess,onError,onSettled), all now consistently including thecontext: MutationFunctionContextparameter. This improves API consistency throughout the documentation.Also applies to: 67-67, 72-72, 76-76, 80-80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR corrects the onMutate function signature in the useMutation reference documentation to include the context parameter, aligning it with the actual API implementation and existing guide examples.
- Updates the
onMutatesignature from(variables: TVariables)to(variables: TVariables, context: MutationFunctionContext) - Brings the reference documentation in line with the actual TypeScript types defined in
query-core - Makes the reference documentation consistent with the guide examples that already demonstrate using the context parameter
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated the onMutate function signature to include context.
🎯 Changes
The method signature, onMutate, is incorrectly specified in the useMutate hook.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
useMutationdocumentation: theonMutatecallback now receives an additional context parameter, providing access to mutation context information during execution.✏️ Tip: You can customize this high-level summary in your review settings.