From 2933943b34f5b88642d658006381aaaa945d7aad Mon Sep 17 00:00:00 2001 From: Damian Stasik <920747+damianstasik@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:00:26 +0200 Subject: [PATCH] Keep previous search results while querying Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> --- frontend/src/q.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/q.ts b/frontend/src/q.ts index 8adc7479..3fe217b1 100644 --- a/frontend/src/q.ts +++ b/frontend/src/q.ts @@ -1,10 +1,15 @@ -import { queryOptions, skipToken } from "@tanstack/react-query"; +import { + keepPreviousData, + queryOptions, + skipToken, +} from "@tanstack/react-query"; import { api } from "@/query"; import { definitions } from "./api"; export const getSearchQuery = (query: string) => queryOptions({ queryKey: ["search", query], + placeholderData: keepPreviousData, queryFn: query.length > 0 ? async ({ signal }) => {