Skip to content

Conversation

@RND332
Copy link

@RND332 RND332 commented Dec 19, 2025

Updated the onMutate function signature to include context.

🎯 Changes

The method signature, onMutate, is incorrectly specified in the useMutate hook.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Documentation
    • Updated useMutation documentation: the onMutate callback 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.

Updated the onMutate function signature to include context.
Copilot AI review requested due to automatic review settings December 19, 2025 09:39
@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2025

⚠️ No Changeset found

Latest commit: 1e5a793

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 19, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

The onMutate callback signature in the React useMutation documentation is updated to include an additional MutationFunctionContext parameter. The callback now receives both variables and context, providing more information to mutation handlers during execution.

Changes

Cohort / File(s) Summary
useMutation API Documentation
docs/framework/react/reference/useMutate.md
Updated onMutate callback signature from onMutate(variables: TVariables) to onMutate(variables: TVariables, context: MutationFunctionContext), adding context parameter to the public API reference.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Verify the signature change is accurate and matches the actual implementation
  • Confirm MutationFunctionContext type is properly imported/referenced in the documentation

Poem

🐰 A context parameter hops into view,
The onMutate callback now knows what to do!
Variables paired with context so bright,
Documentation dances with logic just right! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating the onMutate signature to add a context parameter, which aligns with the changeset.
Description check ✅ Passed The description follows the required template with all key sections completed: changes explained, contributing guide checked, tests run, and release impact clearly marked as docs-only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f15b7fc and 1e5a793.

📒 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 onMutate signature update aligns well with the other callback signatures (mutationFn, onSuccess, onError, onSettled), all now consistently including the context: MutationFunctionContext parameter. This improves API consistency throughout the documentation.

Also applies to: 67-67, 72-72, 76-76, 80-80


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 onMutate signature has been updated to include the context parameter, but the description on line 69 only mentions that it receives "variables" and doesn't reflect the new context parameter being passed. This creates a mismatch between the signature and its documentation.

Align the description with the updated signature to clarify that onMutate receives both variables and context.

🔎 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

📥 Commits

Reviewing files that changed from the base of the PR and between f15b7fc and 1e5a793.

📒 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 onMutate signature update aligns well with the other callback signatures (mutationFn, onSuccess, onError, onSettled), all now consistently including the context: MutationFunctionContext parameter. This improves API consistency throughout the documentation.

Also applies to: 67-67, 72-72, 76-76, 80-80

Copy link

Copilot AI left a 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 onMutate signature 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

SYSTEM_READY >> ...MS