Skip to content

Commit

Permalink
Fix ESLint react-hooks/exhaustive-deps rule
Browse files Browse the repository at this point in the history
  • Loading branch information
CornaSn committed Jul 22, 2024
1 parent 087decc commit f23de61
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/searchExperts/SearchExpertForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { debounce } from 'lodash';
import { cookies } from 'next/headers';
import { useRouter } from 'next/navigation';
import { useEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { Country } from '../../migrations/00004-createCountriesTable';
import { Language } from '../../migrations/00006-createLanguagesTable';
import { Expertise } from '../../migrations/00008-createExpertiseTable';
Expand All @@ -27,7 +27,7 @@ export default function SearchExpertsForm(props: Props) {
const router = useRouter();

// Function to update URL with chosen Options
const debouncedUpdateUrl = useRef(
const debouncedUpdateUrl = useCallback(
debounce(() => {
const query = {
country: selectedCountry ? selectedCountry.toString() : '',
Expand All @@ -37,7 +37,8 @@ export default function SearchExpertsForm(props: Props) {

router.push(`/searchExperts?${searchParams.toString()}`);
}, 300),
).current; // debounce time in milliseconds
[selectedCountry, selectedItemsExpertise],
);

useEffect(() => {
debouncedUpdateUrl();
Expand Down

0 comments on commit f23de61

Please # to comment.