Skip to content

Commit

Permalink
fix(search): move debounce inside of the memo
Browse files Browse the repository at this point in the history
  • Loading branch information
kharann committed May 18, 2021
1 parent b0b1241 commit 56a2cdd
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pages/course/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ const CourseListPage: FC<StaticProps> = ({ departments, faculties }) => {
const [departmentId, setDepartmentId] = useState<number | null>(null);
const [facultyId, setFacultyId] = useState<number | null>(null);
const query = Array.isArray(queryParam) ? queryParam.join(',') : queryParam;
const getSearchUrl = useDebounce(
useMemo(() => getSearchUrlPaginatedGetter(query, sortOrder, departmentId, facultyId), [
query,
sortOrder,
departmentId,
facultyId,
]),
1500
const getSearchUrl = useMemo(
() => useDebounce(getSearchUrlPaginatedGetter(query, sortOrder, departmentId, facultyId), 1000),
[query, sortOrder, departmentId, facultyId]
);
const { data, isValidating, setSize } = useSWRInfinite<ListResponse<Course>>(getSearchUrl);

Expand Down

0 comments on commit 56a2cdd

Please sign in to comment.