diff --git a/CHANGELOG.md b/CHANGELOG.md index a52cbd1a..6b9fc151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Error caused by wrong hooks order on ProductSummaryList ## [2.52.0] - 2020-03-03 ### Added diff --git a/react/ProductSummaryList.js b/react/ProductSummaryList.js index 173c6c05..6eac25e6 100644 --- a/react/ProductSummaryList.js +++ b/react/ProductSummaryList.js @@ -67,8 +67,8 @@ const ProductSummaryList = ({ category, ...(collection != null ? { - collection, - } + collection, + } : {}), specificationFilters: specificationFilters.map(parseFilters), orderBy, @@ -80,15 +80,10 @@ const ProductSummaryList = ({ }, }) - // https://github.com/vtex-apps/product-summary/issues/235 - if (loading || error) { - return null - } - const { list } = useListContext() const { treePath } = useTreePath() - const { products } = data + const { products } = data || {} const newListContextValue = useMemo(() => { const componentList = @@ -108,6 +103,11 @@ const ProductSummaryList = ({ return list.concat(componentList) }, [products, treePath, list]) + // https://github.com/vtex-apps/product-summary/issues/235 + if (loading || error) { + return null + } + return ( {children}