From c7ef58481bd87d23ab41ed322f5b7b8c6d1d590f Mon Sep 17 00:00:00 2001 From: Jelle van Snik Date: Tue, 3 May 2022 21:06:27 +0200 Subject: [PATCH] fix rerender issues --- src/hooks/useSearchQuery.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hooks/useSearchQuery.ts b/src/hooks/useSearchQuery.ts index f03d4668..7a1bb329 100644 --- a/src/hooks/useSearchQuery.ts +++ b/src/hooks/useSearchQuery.ts @@ -8,7 +8,7 @@ export function useSearchQuery(): [ () => void ] { const history = useHistory(); - const isFirstRender = useRef(false); + const isFirstRender = useRef(true); const { path, params } = useRouteMatch<{ type: string; query: string }>(); const [search, setSearch] = useState({ searchQuery: "", @@ -40,11 +40,10 @@ export function useSearchQuery(): [ // only run on first load of the page React.useEffect(() => { - if (isFirstRender.current === true) { - isFirstRender.current = false; + if (isFirstRender.current === false) { return; } - isFirstRender.current = true; + isFirstRender.current = false; const type = Object.values(MWMediaType).find((v) => params.type === v) || MWMediaType.MOVIE;