-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Upgrade react-query to v5, react 18 and yarn v4 #9473
Conversation
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.
Review status: 25%
packages/ra-core/src/controller/field/useReferenceManyFieldController.ts
Show resolved
Hide resolved
packages/ra-core/src/controller/list/useInfiniteListController.ts
Outdated
Show resolved
Hide resolved
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.
Review status: 50%
examples/demo/src/authProvider.ts
Outdated
@@ -13,7 +13,7 @@ const authProvider: AuthProvider = { | |||
checkError: () => Promise.resolve(), | |||
checkAuth: () => | |||
localStorage.getItem('username') ? Promise.resolve() : Promise.reject(), | |||
getPermissions: () => Promise.resolve(), | |||
getPermissions: () => Promise.resolve([]), |
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.
Why do we need it? getPermissions should be able to return undefined
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.
Then we must handle the undefined case in the hook
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.
Handled at the hook level
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.
Then you need to revert this change
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.
Wow, this is impressive! Kudos for this PR.
packages/ra-ui-materialui/src/list/filter/FilterButton.spec.tsx
Outdated
Show resolved
Hide resolved
packages/ra-ui-materialui/src/list/pagination/PaginationActions.tsx
Outdated
Show resolved
Hide resolved
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.
Congrats, this PR is 💯
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.
Review still in progress, but making a save point here bc my screen starts to freeze to much 😅
|
||
## Use `@tanstack/react-query` instead of `react-query` | ||
|
||
React-admin now uses `react-query` v5 instead of v3. The library name has changed to `@tanstack/react-query` (but it's almost the same API). |
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.
React-admin now uses `react-query` v5 instead of v3. The library name has changed to `@tanstack/react-query` (but it's almost the same API). | |
React-admin now uses `tanstack-query` v5 instead of `react-query` v3. The library name has changed to `@tanstack/react-query` (but it's almost the same API). |
Shouldn't we use the name tanstack-query instead of react-query from now on?
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.
Still WIP...
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.
Review status: 70%
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.
Review complete! Now to do some testing...
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
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.
🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉
Following #9473, we should use `isPending` in our demos (even though `isLoading` still works) as it's the best practice.
Problems
Solution
data
Breaking changes
React 18
React-admin v5 uses React 18. If you use react-admin as a library in your own application, you'll have to upgrade to React 18 as well.
The React team has published a migration guide to help you upgrade. On most projects, this should be a matter of updating the root file of your application:
React 18 adds out-of-the-box performance improvements by doing more batching by default.
Drop support for IE11
React-admin v5 uses React 18, which dropped support for Internet Explorer. If you need to support IE11, you'll have to stay on react-admin v4.
Rename
isLoading
toisPending
in mutationsIn the return state of data provider mutation hooks,
isLoading
has been renamed toisPending
to be consistent with the same change in react-query.The following hooks are impacted by this change:
useCreate
useDelete
useDeleteMany
useUpdate
useUpdateMany
useDeleteWithUndoController
useDeleteWithConfirmController
If you use these hooks, replace
isLoading
byisPending
:Use
data
in Authentication hooks return valueHooks that call the
authProvider
now return thedata
property of the result instead of a variable named after the hook.The following hooks are impacted by this change:
useAuthState
useIdentity
usePermissions
If you use these hooks, replace the variable name by
data
:Use
@tanstack/react-query
instead ofreact-query
React-admin now uses
react-query
v5 instead of v3. The library name has changed to@tanstack/react-query
(but it's almost the same API).If you used
react-query
directly in your code, you'll have to update it, following their migration guides:Here is a focus of the most important changes.
The package has been renamed to
@tanstack/react-query
so you'll have to change your imports:All react-query hooks,
queryClient
andqueryCache
methods now accept a single object argument:Removed deprecated hooks
The following deprecated hooks have been removed
usePermissionsOptimized
. UseusePermissions
instead.