From 53e8424041d1b6765d03fcf61d6d6e754b51c4c8 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 26 Jun 2020 22:48:21 -0700 Subject: [PATCH] fix: disabling query in suspense mode (#643) --- src/react/tests/suspense.test.js | 25 +++++++++++++++++++++++++ src/react/utils.js | 6 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/react/tests/suspense.test.js b/src/react/tests/suspense.test.js index 81d405ad4f..e30de2605e 100644 --- a/src/react/tests/suspense.test.js +++ b/src/react/tests/suspense.test.js @@ -151,4 +151,29 @@ describe("useQuery's in Suspense mode", () => { await waitFor(() => rendered.getByText('rendered')) }) + + it('should not call the queryFn when not enabled', async () => { + const queryFn = jest.fn() + queryFn.mockImplementation(() => sleep(10)) + + function Page() { + const [enabled, setEnabled] = React.useState(false) + useQuery(['test'], queryFn, { suspense: true, enabled }) + + return