Skip to content

Commit

Permalink
fix: use native replaceState instead of router (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
smbdy committed Feb 29, 2024
1 parent 75d903b commit 9afe436
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ui/src/components/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { usePathname, useSearchParams } from 'next/navigation';
import { cn } from '@/utils/cn';
import { type Address } from '@/types';
import Fuse, { FuseResult } from 'fuse.js';
Expand All @@ -20,7 +20,6 @@ const SEARCH_LIMIT = 32;
const DEBOUNCE_TIME = 150;

export const Search = ({ addresses }: { addresses: Address[] }) => {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();

Expand Down Expand Up @@ -54,7 +53,7 @@ export const Search = ({ addresses }: { addresses: Address[] }) => {
}
timeoutId.current = setTimeout(() => {
if (search) {
router.push(`${pathname}?q=${search}`);
window.history.replaceState(null, '', `${pathname}?q=${search}`);
}
performSearch(search);
}, DEBOUNCE_TIME);
Expand All @@ -63,7 +62,7 @@ export const Search = ({ addresses }: { addresses: Address[] }) => {
clearTimeout(timeoutId.current);
}
};
}, [search, performSearch, router, pathname]);
}, [search, performSearch, pathname]);

return (
<div className="w-full max-w-2xl mb-10">
Expand Down

0 comments on commit 9afe436

Please sign in to comment.