-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(react-query): add react@19 as peerDeps #9310
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
base: v4
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 7c44694
☁️ Nx Cloud last updated this comment at |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7c44694:
|
I can't reproduce the issue in the local test environment. Is there a problem with the CI pipeline? |
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.
I’m in favor of adding React 19 to the peerDependencies of @tanstack/react-query v4.
Since it seems that @TkDodo previously opposed this change, I wanted to tag you and check if you’re okay with it before merging.
From what I understand, there’s nothing in @tanstack/react-query v4 that should cause issues with React 19.
If there are any problems, I’d expect them to be due to changes in React itself — so I think it should be safe to go ahead with the merge. Would that be alright with you?
we can bump the peerDependency if everything works at runtime, but I don’t think we’re running tests against react19. |
@gwansikk appreciate the PR here, really timely as I'm about to do a major migration to v5 just to support React 19. Do you have any timeline on this? |
The current work is in its final stages. However, in order for the PR to be merged, sufficient discussion with the maintainer is necessary. |
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Latest passing test: |
NX CI is broken; all tests pass locally. |
This PR is fully prepared. Could you please take a look? |
I'll see this until next week. |
|
|
||
it('should be able to throw an error when useErrorBoundary is a function that returns true', async () => { | ||
let boundary = false | ||
let callBoundaryCount = 0 |
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.
When useErrorBoundary
is passed as a function to useMutation
,
in React 19, this function is called three times, and since the last call returns false
,
the error is not passed to the ErrorBoundary but instead rendered inside the component.
(In React 18, it was called twice and worked correctly.)
Due to React 19's changed render sequence, the React Query Observer runs three times.
To fix this, we are updating the logic to a count-based approach that doesn't rely on render counts (i.e., not using !boundary
logic).
expect(states.length).toBe(reactVersion() === '18' ? 6 : 7), | ||
) | ||
|
||
if (reactVersion() === '18') { |
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.
This part also has different state tests due to the changed render sequence in React 19.
We’ve clearly separated the handling logic according to each React version.
@manudeli All test adaptations have been completed! What I’d like to convey to the maintainer is that the test environment is tightly coupled with the internal render behavior (number of renders), which varies depending on the React version. |
related: #8441
I'm the maintainer of Suspensive (a community project for React Query), who previously submitted a PR regarding React 19 support in React Query v4.
This PR, I'd like to explicitly specify React 19 in the
peerDependencies
instead of thedependencies
. React Query v4 is already compatible with React 19 without any code changes, and we've confirmed this through the following steps:pnpm pack
) with React 19 specified inpeerDependencies
There are no breaking changes in React 19 that affect compatibility, and v4 works reliably without special handling. If issues do arise, they would likely be due to changes in React 19, not React Query v4 itself.
Currently, since React 19 is not listed in
peerDependencies
, usingreact-query@v4
in a React 19 environment causes the following problems: