Repository navigation
Fix incompatibility with latest react-query - #10964
Conversation
There was a problem hiding this comment.
Pull Request Overview
Updates react-query dependency to version 5.90.2 to address a breaking change introduced in version 5.89.0. The changes ensure compatibility with both the latest version and older versions of react-query by adapting callback function signatures.
- Updates react-query dependency across multiple packages from ^5.83.0 to ^5.90.2
- Modifies callback handlers to use spread operator pattern for version compatibility
- Updates type definitions for OnSuccess and OnError callbacks to include additional parameters
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react-admin/package.json | Updates react-query dependency version |
| packages/ra-ui-materialui/package.json | Updates react-query dependency version |
| packages/ra-no-code/package.json | Updates react-query dependency version |
| packages/ra-core/package.json | Updates react-query and devtools dependency versions |
| examples/simple/package.json | Updates react-query and devtools dependency versions |
| packages/ra-core/src/types.ts | Adds onMutateResult parameter to OnSuccess and OnError type definitions |
| packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx | Updates callback handlers to use spread operator for compatibility |
| packages/ra-core/src/dataProvider/*.ts | Updates all data provider hooks to use spread operator pattern in callbacks |
| packages/ra-core/src/controller/*.ts | Updates controller hooks to use spread operator pattern in callbacks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
slax57
left a comment
There was a problem hiding this comment.
Other than that everything LGTM. I have not been able to find any signs of a possible regression brought by this PR.
| { snapshot: snapshot.current }, | ||
| { | ||
| client: queryClient, | ||
| mutationKey: [resource, 'create', params], |
There was a problem hiding this comment.
While reviewing I wondered if we shouldn't use callTimeParams here instead, but I realize that we use the same mutationKey while creating the mutation, which may (or may not) be wrong.
In any case, at least it's consistent, so I guess we can ignore this for the context of this PR...
There was a problem hiding this comment.
It should be the same query key as the one passed to useMutation otherwise it will cause issue with offline as you won't be able to target the mutation
| { | ||
| client: queryClient, | ||
| mutationKey: [resource, 'create', params], | ||
| meta: mutationOptions.meta, |
There was a problem hiding this comment.
Here however I wonder if you shouldn't use callTimeMeta instead...
There was a problem hiding this comment.
Nope, that's react-query meta, not react-admin meta
There was a problem hiding this comment.
I know we actually override them but this is the 4th parameter introduced in latest react-query and I think we should follow the same rule as the query key here
Problem
Latest react-query (
5.89.0) introduced a 4th parameter to all mutation side effect functions (onSucces,onError,onSettledandonMutate) which is a breaking change for us (react-admin won't compile with this version).Our main issue is that we call those functions ourselves in
optimisticandundoablemutation modes.Solution
Fix it so that it works with whatever version our users are using
How To Test
make install buildnpm create react-adminnode_modules(make sure to delete./node_modules/react-admin/node_moduleswhich only exists in our monorepo and shouldn't be copied)onSuccessto see it shows the type for react-query5.89.0.react-queryolder that5.89.0(for instance5.87.4)npm install @tanstack/react-query@5.87.4onSuccessagain to see it shows the type for react-query5.87.4.Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a featureAlso, please make sure to read the contributing guidelines.