Skip to content

Commit

Permalink
Merge pull request #92 from vtex-apps/fix/missing-search-query-v2x
Browse files Browse the repository at this point in the history
fix error when serachquery is missing
  • Loading branch information
hiagolcm authored Sep 8, 2020
2 parents f2704cb + 5a6bdff commit 89d0929
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Error when the `searchQuery` is missing.

## [2.0.0] - 2020-08-18

### Removed
Expand Down
12 changes: 8 additions & 4 deletions react/components/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ const Banner = (props: BannerProps) => {
const CSS_HANDLES = ["searchBanner"];
const handles = useCssHandles(CSS_HANDLES);

const { searchQuery } = useSearchPage();

if (!searchQuery) {
return null;
}

const {
searchQuery: {
variables: { fullText, selectedFacets },
},
} = useSearchPage();
variables: { fullText, selectedFacets },
} = searchQuery;

const { loading, data } = useQuery(bannersQuery, {
variables: {
Expand Down

0 comments on commit 89d0929

Please sign in to comment.