Make all mutations react to their declaration time options changes#10857
Merged
fzaninotto merged 3 commits intonextfrom Aug 29, 2025
Merged
Make all mutations react to their declaration time options changes#10857fzaninotto merged 3 commits intonextfrom
fzaninotto merged 3 commits intonextfrom
Conversation
fzaninotto
requested changes
Jul 30, 2025
Member
fzaninotto
left a comment
There was a problem hiding this comment.
1% code, 99% stories and tests, we're good ;)
| ]; | ||
| const dataProvider = { | ||
| getList: (resource, params) => { | ||
| console.log('getList', resource, params); |
Member
There was a problem hiding this comment.
you should not leave the console.log here (same in delete and in other hook tests)
| ]; | ||
| const dataProvider = { | ||
| getList: (resource, params) => { | ||
| console.log('getList', resource, params); |
Member
There was a problem hiding this comment.
I think you should remove these logs and the console.log mocking on the test. These may have been useful during development, but now the story is explicit enough (and testable enough) not to rely on logs.
Besides, the test aren't reverting the mock on console.log.
| ]; | ||
| const defaultDataProvider = { | ||
| getList: (resource, params) => { | ||
| console.log('getList', resource, params); |
Member
There was a problem hiding this comment.
same, console.log is useless in tests
fzaninotto
approved these changes
Aug 29, 2025
djhi
added a commit
that referenced
this pull request
Oct 3, 2025
… 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.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The mutation hooks currently put the
mutationModeandparamsthey receive at declaration time in a ref but never update them from their props.Solution
Add effects that sync the refs with the props.
How To Test
Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a featureAlso, please make sure to read the contributing guidelines.