Skip to content

Commit

Permalink
fix use-page-query-params lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Assem-Hafez committed Apr 6, 2024
1 parent f006199 commit 05119be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hooks/use-page-query-params/use-page-query-params.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import usePreviousValue from '@/hooks/usePreviousValue';
import type { PageQueryParamConfig, PageQueryParamsSetter, QueryParamSetterExtraConfig, QueryParamsSetterObject, QueryParamsValues } from './types';
import { getPageQueryParamsValues, getUpdatedUrlSearch } from './utils';

const use_Shared_HistoryState = () => useBetween(useState<string>);
const useShared_HistoryState = () => useBetween(useState<string>);

export default function usePageQueryParams(
configs: PageQueryParamConfig[],
extraConfig?: QueryParamSetterExtraConfig
): [QueryParamsValues, PageQueryParamsSetter] {
// state shared across all usePageQueryParams instances so that when one of the hook uses history state (which doesn't cause full page rerender)
// other usePageQueryParams hooks will get rerendered and update their internal value of window.location.search
const [stateUrl, rerender] = use_Shared_HistoryState()
const [stateUrl, rerender] = useShared_HistoryState()
const searchQueryParams = useSearchParams();
const pathname = usePathname();
const router = useRouter()
Expand All @@ -26,7 +26,7 @@ export default function usePageQueryParams(
// otherwise we get it from searchQueryParams
if (prevStateUrl !== stateUrl) return window.location.search;
return searchQueryParams.toString();
}, [searchQueryParams, stateUrl]);
}, [searchQueryParams, stateUrl, prevStateUrl]);

const values = useMemo(() => {
const urlQueryParamsObject = queryString.parse(search);
Expand All @@ -53,7 +53,7 @@ export default function usePageQueryParams(
rerender(newHref);
}
},
[extraConfig?.replace, extraConfig?.pageRerender, search, configs, router.replace, router.push, pathname, rerender];
[extraConfig?.replace, extraConfig?.pageRerender, search, configs, router.replace, router.push, pathname, rerender]
);

return [values, setter];
Expand Down

0 comments on commit 05119be

Please sign in to comment.