Skip to content

Commit

Permalink
useMutation: use useIsomorphicLayoutEffect instead of `useLayoutE…
Browse files Browse the repository at this point in the history
…ffect` (#11900)
  • Loading branch information
phryneas authored Jun 21, 2024
1 parent a739dfd commit f745558
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-icons-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

`useMutation`: use `useIsomorphicLayoutEffect` instead of `useLayoutEffect`
2 changes: 1 addition & 1 deletion .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 39561,
"dist/apollo-client.min.cjs": 39579,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32821
}
3 changes: 2 additions & 1 deletion src/react/hooks/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { equal } from "@wry/equality";
import { DocumentType, verifyDocumentType } from "../parser/index.js";
import { ApolloError } from "../../errors/index.js";
import { useApolloClient } from "./useApolloClient.js";
import { useIsomorphicLayoutEffect } from "./internal/useIsomorphicLayoutEffect.js";

/**
*
Expand Down Expand Up @@ -99,7 +100,7 @@ export function useMutation<
options,
});

React.useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
Object.assign(ref.current, { client, options, mutation });
});

Expand Down

0 comments on commit f745558

Please sign in to comment.