Skip to content

Commit eefb70a

Browse files
author
Marcin Kwiatkowski
authored
fix(homepage): fixed new products carousel ssr rendering issues (#736)
1 parent 67fcc26 commit eefb70a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/theme/pages/Home.vue

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ import {
9797
SfCallToAction,
9898
SfBannerGrid,
9999
} from '@storefront-ui/vue';
100-
import { productGetters } from '~/getters';
101100
102101
import {
103102
computed,
104103
defineComponent,
105104
ref,
106105
useContext,
107-
useFetch,
106+
useAsync,
108107
} from '@nuxtjs/composition-api';
109108
import LazyHydrate from 'vue-lazy-hydration';
110109
import { useCache, CacheTagPrefix } from '@vue-storefront/cache';
110+
import { productGetters } from '~/getters';
111111
import { useProduct } from '~/composables';
112112
import MobileStoreBanner from '~/components/MobileStoreBanner.vue';
113113
import InstagramFeed from '~/components/InstagramFeed.vue';
@@ -133,10 +133,7 @@ export default defineComponent({
133133
const { addTags } = useCache();
134134
const { app } = useContext();
135135
const year = new Date().getFullYear();
136-
const products = ref({});
137-
138136
const { getProductList, loading: newProductsLoading } = useProduct();
139-
140137
const heroes = ref([
141138
{
142139
title: app.i18n.t('Colorful summer dresses are already in store'),
@@ -243,20 +240,22 @@ export default defineComponent({
243240
},
244241
]);
245242
246-
// @ts-ignore
247-
const newProducts = computed(() => productGetters.getFiltered(products.value?.items, { master: true }));
248-
249-
useFetch(async () => {
250-
products.value = await getProductList({
243+
const products = useAsync(async () => {
244+
const productsData = await getProductList({
251245
pageSize: 10,
252246
currentPage: 1,
253247
sort: {
254248
position: 'ASC',
255249
},
256250
});
251+
257252
addTags([{ prefix: CacheTagPrefix.View, value: 'home' }]);
253+
return productsData;
258254
});
259255
256+
// @ts-ignore
257+
const newProducts = computed(() => productGetters.getFiltered(products.value?.items, { master: true }));
258+
260259
return {
261260
banners,
262261
heroes,

0 commit comments

Comments
 (0)