-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
useMutation: fix rules of React violations #11852
Conversation
🦋 Changeset detectedLatest commit: a733eb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -1348,7 +1348,7 @@ describe("General Mutation testing", () => { | |||
if (count === 0) { | |||
expect(result.called).toEqual(false); | |||
expect(result.loading).toEqual(false); | |||
createTodo(); | |||
setTimeout(createTodo, 10); |
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 is what that TODO comment was referencing to:
TODO: Trying to assign these in a useEffect or useLayoutEffect breaks higher-order components.
It didn't break HOCs, but broke the test that was calling createTodo
during render.
const result = { | ||
called: false, | ||
loading: false, | ||
client: ref.current.client, |
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.
Woops 🙃
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.
Looks good to me!
@phryneas This PR has introduced a You might need to consider guarding against this with some of the solutions suggested at https://reactjs.org/link/uselayouteffect-ssr |
We're seeing a lot of warnings after the introduction of useLayoutEffect, so we downgraded to 3.10.4 again. |
also downgraded to 3.10.4. Got useLayoutEffect warnings for every useMutation |
@mikehdt @Multiply @quadrifolia thank y'all for the report! I'll see that I get a patch for this out at some point today or tomorrow! |
@mikehdt @Multiply @quadrifolia could you please try out this build and report back if that solves the problem? npm i @apollo/client@0.0.0-pr-11900-20240620115719 |
The error seems to be gone with that version of @apollo/client indeed. |
@mikehdt @Multiply @quadrifolia I just released 3.10.6 which should address your problem. |
Another one for #11511...