diff --git a/.changeset/clean-icons-sparkle.md b/.changeset/clean-icons-sparkle.md new file mode 100644 index 00000000000..15ff01dbf8d --- /dev/null +++ b/.changeset/clean-icons-sparkle.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +`useMutation`: use `useIsomorphicLayoutEffect` instead of `useLayoutEffect` diff --git a/.size-limits.json b/.size-limits.json index 5c28672b1f7..4db1f2681bf 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -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 } diff --git a/src/react/hooks/useMutation.ts b/src/react/hooks/useMutation.ts index 65f0820e015..ea0f47ddc6c 100644 --- a/src/react/hooks/useMutation.ts +++ b/src/react/hooks/useMutation.ts @@ -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"; /** * @@ -99,7 +100,7 @@ export function useMutation< options, }); - React.useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { Object.assign(ref.current, { client, options, mutation }); });