Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix website component search #2371

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import PageContent from '../../PageContent'
import { ComponentsSearch } from './ComponentsSearch'
import { ComponentsFilters } from './ComponentsFilters'
import { ComponentsGrid } from './ComponentsGrid'
import { navigate } from 'gatsby'

interface ComponentsExplorerProps {
location: {
search: string
}
navigate: (
path: string,
options?: {
replace?: boolean
}
) => void
}

export const ComponentsExplorer = ({ location, navigate }: ComponentsExplorerProps) => {
export const ComponentsExplorer = ({ location }: ComponentsExplorerProps) => {
const [term, filter] = useMemo(() => {
const params = new URLSearchParams(location.search)
return [params.get('q'), params.get('filter')]
Expand All @@ -35,7 +30,7 @@ export const ComponentsExplorer = ({ location, navigate }: ComponentsExplorerPro
replace: true,
})
},
[filter, navigate]
[filter]
)
const handleFilter = useCallback(
(filter: string | null) => {
Expand All @@ -45,7 +40,7 @@ export const ComponentsExplorer = ({ location, navigate }: ComponentsExplorerPro

navigate(`/components/?${params.toString()}`)
},
[term, navigate]
[term]
)

return (
Expand Down
10 changes: 2 additions & 8 deletions website/src/pages/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@ interface ComponentsProps {
location: {
search: string
}
navigate: (
path: string,
options?: {
replace?: boolean
}
) => void
}

const Components = ({ location, navigate }: ComponentsProps) => {
const Components = ({ location }: ComponentsProps) => {
return (
<Layout>
<Seo title="Components" />
<ComponentsExplorer location={location} navigate={navigate} />
<ComponentsExplorer location={location} />
</Layout>
)
}
Expand Down