Skip to content

Commit

Permalink
Use navigate from gatsby
Browse files Browse the repository at this point in the history
  • Loading branch information
aautem committed Jun 20, 2023
1 parent 31ce26a commit e35e3c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
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

0 comments on commit e35e3c8

Please sign in to comment.