This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FSSS-172] Fix/Adjust inappropriate rerenders (#304)
- Loading branch information
1 parent
fe9618e
commit 9302081
Showing
18 changed files
with
102 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { memo } from 'react' | ||
|
||
import type { BreadcrumbProps } from '.' | ||
import Breadcrumb from '.' | ||
|
||
interface BreadcrumbWrapperProps | ||
extends Partial<Pick<BreadcrumbProps, 'breadcrumbList'>> { | ||
name: string | ||
} | ||
|
||
const BreadcrumbWrapper = ({ | ||
breadcrumbList, | ||
name, | ||
}: BreadcrumbWrapperProps) => { | ||
const fallback = [{ item: '/', name, position: 1 }] | ||
const list = breadcrumbList ?? fallback | ||
|
||
return <Breadcrumb breadcrumbList={list} /> | ||
} | ||
|
||
export default memo(BreadcrumbWrapper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default } from './Breadcrumb' | ||
export { default as BreadcrumbWrapper } from './BreadcrumbWrapper' | ||
export type { BreadcrumbProps } from './Breadcrumb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { SearchState } from '@faststore/sdk' | ||
import { parseSearchState } from '@faststore/sdk' | ||
import type { | ||
CollectionPageQueryQuery, | ||
CollectionPageQueryQueryVariables, | ||
} from '@generated/graphql' | ||
import type { PageProps } from 'gatsby' | ||
import { useMemo } from 'react' | ||
|
||
export type Props = PageProps< | ||
CollectionPageQueryQuery, | ||
CollectionPageQueryQueryVariables | ||
> & { slug: string } | ||
|
||
export const useSearchParams = (props: Props): SearchState => { | ||
const { | ||
location: { href, pathname }, | ||
data, | ||
} = props | ||
|
||
const selectedFacets = data?.collection?.meta.selectedFacets | ||
|
||
return useMemo(() => { | ||
const maybeState = href ? parseSearchState(new URL(href)) : null | ||
|
||
return { | ||
page: maybeState?.page ?? 0, | ||
base: maybeState?.base ?? pathname, | ||
selectedFacets: | ||
maybeState && maybeState.selectedFacets.length > 0 | ||
? maybeState.selectedFacets | ||
: selectedFacets ?? [], | ||
term: maybeState?.term ?? null, | ||
sort: maybeState?.sort ?? 'score_desc', | ||
} | ||
}, [href, pathname, selectedFacets]) | ||
} |
Oops, something went wrong.