From ab6585ca0cb4e7b41467ee87bfbe69467e940d73 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Mon, 27 Jun 2022 15:14:53 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=80=20Added=20debounce=20to=20global?= =?UTF-8?q?=20searchbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/GlobalSearchBar/SearchBar.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/components/GlobalSearchBar/SearchBar.tsx b/src/client/components/GlobalSearchBar/SearchBar.tsx index 5cb76b4..5092e7c 100644 --- a/src/client/components/GlobalSearchBar/SearchBar.tsx +++ b/src/client/components/GlobalSearchBar/SearchBar.tsx @@ -1,4 +1,4 @@ -import { debounce, isEmpty, isUndefined, map } from "lodash"; +import { debounce, isEmpty, map } from "lodash"; import React, { ReactElement, useCallback, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import Card from "../Carda"; @@ -17,7 +17,7 @@ export const SearchBar = (data: ISearchBarProps): ReactElement => { ); const performSearch = useCallback( - (e) => { + debounce((e) => { dispatch( searchIssue( { @@ -34,7 +34,7 @@ export const SearchBar = (data: ISearchBarProps): ReactElement => { }, ), ); - }, + }, 500), [data], ); return ( @@ -67,7 +67,11 @@ export const SearchBar = (data: ISearchBarProps): ReactElement => { imageStyle={{ maxWidth: 70 }} titleStyle={{ fontSize: "0.8rem" }} tagsStyle={{ fontSize: "0.7rem" }} - containerStyle={{ width: "100vw", padding: 0, margin: "0 0 8px 0" }} + containerStyle={{ + width: "100vw", + padding: 0, + margin: "0 0 8px 0", + }} /> ))}