Skip to content

Commit

Permalink
Fix search not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Studio384 committed Apr 29, 2024
1 parent 11bb894 commit 4e2dd43
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions docs/src/app/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useCallback, useMemo } from 'react';
import { useSearchParams } from 'react-router-dom';

import {
Expand Down Expand Up @@ -52,7 +52,7 @@ export default function Icons() {
// c: categories
// q: query
// p: page
function setSearchQuery(type: 'q' | 'c' | 'p', value: string | number) {
const setSearchQuery = useCallback((type: 'q' | 'c' | 'p', value: string | number) => {
let search = searchParams.get('search');
let page = Number(searchParams.get('page'));
let category =
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function Icons() {
search: search ?? '',
category: category.join(',') ?? ''
});
}
}, [searchParams, setSearchParams]);

return (
<>
Expand Down Expand Up @@ -161,10 +161,7 @@ export default function Icons() {
startDecorator={<Amicon icon={aiMagnifyingGlass} />}
placeholder="Search"
value={searchQuery}
onChange={(e) => {
setSearchQuery('q', e.target.value);
setSearchQuery('p', 1);
}}
onChange={(e) => setSearchQuery('q', e.target.value)}
/>
<IconButton
variant="outlined"
Expand Down

0 comments on commit 4e2dd43

Please sign in to comment.