Skip to content

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Oct 3, 2025

Problem

After #10857, when passing parameters at declaration time to a mutation hook in optimistic or undoable mode, those params may be modified by the side effects before the actual mutation is called.

For instance, if you pass the selectedIds from the ListContext to a useUpdateMany hook and use the useUnselectAll hook to reset the selectedIds in the onSuccess side effect, then the actual mutation will be called with an empty array of ids.

You can see the issue like this:

Solution

Keep the params in an additional ref that is freezed once the mutate callback is called.

How To Test

  • make run
  • http://localhost:8080/#/posts
  • select multiple rows and click the Reset views button
  • check the dataProvider call in the console and ensure the correct ids were passed to updateMany

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)

… may pass invalid parameters to the mutation

## Problem

After #10857, when passing parameters at declaration time to a mutation hook in `optimistic` or `undoable` mode, those params may be modified by the side effects before the actual mutation is called.

For instance, if you pass the `selectedIds` from the `ListContext` to a `useUpdateMany` hook and use the `useUnselectAll` hook to reset the `selectedIds` in the `onSuccess` side effect, then the actual mutation will be called with an empty array of ids.

## Solution

Keep the params in an additional ref that is freezed once the `mutate` callback is called.
@djhi djhi added the RFR Ready For Review label Oct 3, 2025
@djhi djhi added this to the 5.12.0 milestone Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Development

Successfully merging this pull request may close these issues.

1 participant