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 search-result ssr #648

Merged
merged 2 commits into from
Dec 7, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Search result ssr

## [3.128.0] - 2023-11-28

### Added
Expand Down
6 changes: 2 additions & 4 deletions react/components/SearchQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function getCookie(cname) {
if (!canUseDOM) {
return null
return undefined
}

const name = `${cname}=`
Expand All @@ -39,7 +39,7 @@
}
}

return ''
return undefined
}

const DEFAULT_PAGE = 1
Expand Down Expand Up @@ -126,7 +126,7 @@

const isCurrentDifferent = (ref, currentVal) => ref.current !== currentVal

const useShouldResetPage = (query, map, orderBy, priceRange) => {

Check warning on line 129 in react/components/SearchQuery.js

View workflow job for this annotation

GitHub Actions / Lint

Arrow function has too many parameters (4). Maximum allowed is 3
const queryRef = useRef(query)
const mapRef = useRef(map)
const orderByRef = useRef(orderBy)
Expand Down Expand Up @@ -155,7 +155,7 @@
operator,
searchState,
fullText
) => {

Check warning on line 158 in react/components/SearchQuery.js

View workflow job for this annotation

GitHub Actions / Lint

Arrow function has too many parameters (4). Maximum allowed is 3
const fullTextRef = useRef(fullText)
const shouldReset = isCurrentDifferent(fullTextRef, fullText)

Expand Down Expand Up @@ -190,15 +190,13 @@
facetsArgs,
price,
sponsoredProductsBehavior = 'skip'
) => {

Check warning on line 193 in react/components/SearchQuery.js

View workflow job for this annotation

GitHub Actions / Lint

Arrow function has too many parameters (4). Maximum allowed is 3
const { getSettings, query: runtimeQuery } = useRuntime()
const settings = getSettings('vtex.store')

const isLazyFacetsFetchEnabled = settings?.enableFiltersFetchOptimization

const productSearchResult = useQuery(productSearchQuery, {
ssr: false,
skip: !canUseDOM,
variables: {
...variables,
variant: getCookie('sp-variant'),
Expand Down
Loading