How to reset the URL to the first page of pagination whenever there is a change to the URL parameters?
export const Filters = ({ data, valueKey, name }: Props) => { const searchParams = useSearchParams(); const router = useRouter(); const selectedValue = searchParams.get(valueKey); const onClick = (slug: string | undefined) => { const currentPath = qs.parse(searchParams.toString()); const query = { …currentPath, [valueKey]: slug, }; if (currentPath[valueKey] === slug) { query[valueKey] = null; } const […]
How to go back to the first page of pagination whenever there is a change to the URL parameters?
export const Filters = ({ data, valueKey, name }: Props) => { const searchParams = useSearchParams(); const router = useRouter(); const selectedValue = searchParams.get(valueKey); const onClick = (slug: string | undefined) => { const currentPath = qs.parse(searchParams.toString()); const query = { …currentPath, [valueKey]: slug, }; if (currentPath[valueKey] === slug) { query[valueKey] = null; } const […]
How to go back to the first page of pagination whenever there is a change to the URL parameters?
export const Filters = ({ data, valueKey, name }: Props) => { const searchParams = useSearchParams(); const router = useRouter(); const selectedValue = searchParams.get(valueKey); const onClick = (slug: string | undefined) => { const currentPath = qs.parse(searchParams.toString()); const query = { …currentPath, [valueKey]: slug, }; if (currentPath[valueKey] === slug) { query[valueKey] = null; } const […]
How to go back to the first page of pagination whenever there is a change to the URL parameters?
export const Filters = ({ data, valueKey, name }: Props) => { const searchParams = useSearchParams(); const router = useRouter(); const selectedValue = searchParams.get(valueKey); const onClick = (slug: string | undefined) => { const currentPath = qs.parse(searchParams.toString()); const query = { …currentPath, [valueKey]: slug, }; if (currentPath[valueKey] === slug) { query[valueKey] = null; } const […]