From 6e3aeb1fae2da2ef1d987499ad2e9baf40bd0eae Mon Sep 17 00:00:00 2001 From: Nathan Knight Date: Fri, 23 Jun 2023 14:17:09 -0400 Subject: [PATCH] fix(react): Avoid using stale deps from closure when executing query in useQuery --- .changeset/mean-zebras-itch.md | 5 +++++ packages/react-urql/src/hooks/useQuery.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-zebras-itch.md diff --git a/.changeset/mean-zebras-itch.md b/.changeset/mean-zebras-itch.md new file mode 100644 index 0000000000..463e0767c9 --- /dev/null +++ b/.changeset/mean-zebras-itch.md @@ -0,0 +1,5 @@ +--- +'urql': patch +--- + +Fix re-executing operation with stale deps in useQuery diff --git a/packages/react-urql/src/hooks/useQuery.ts b/packages/react-urql/src/hooks/useQuery.ts index 1b14e8b5ab..78ee917112 100644 --- a/packages/react-urql/src/hooks/useQuery.ts +++ b/packages/react-urql/src/hooks/useQuery.ts @@ -368,7 +368,7 @@ export function useQuery< }) ) : client.executeQuery(request, context); - return [source, state[1], deps]; + return [source, state[1], state[2]]; }); }, [