Skip to content

Commit f9035e5

Browse files
committed
Remove useCustomerWishlistSkus hook from Carousel and Gallery components and add in useApp talon to avoid infinite loop
1 parent 78280c8 commit f9035e5

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

packages/pagebuilder/lib/ContentTypes/Products/Carousel/__tests__/useCarousel.spec.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ import defaultOperations from '../carousel.gql';
1515
import mosOperations from '../carousel.gql.ce';
1616
import acOperations from '../carousel.gql.ee';
1717

18-
jest.mock(
19-
'@magento/peregrine/lib/hooks/useCustomerWishlistSkus/useCustomerWishlistSkus',
20-
() => ({
21-
useCustomerWishlistSkus: jest.fn()
22-
})
23-
);
24-
2518
const cache = new InMemoryCache({
2619
typePolicies
2720
});

packages/pagebuilder/lib/ContentTypes/Products/Carousel/useCarousel.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useQuery } from '@apollo/client';
22

3-
import { useCustomerWishlistSkus } from '@magento/peregrine/lib/hooks/useCustomerWishlistSkus/useCustomerWishlistSkus';
4-
53
import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
64
import defaultOperations from './carousel.gql';
75

@@ -11,8 +9,6 @@ import defaultOperations from './carousel.gql';
119
export const useCarousel = (props = {}) => {
1210
const operations = mergeOperations(defaultOperations, props.operations);
1311

14-
useCustomerWishlistSkus();
15-
1612
const { data: storeConfigData } = useQuery(operations.getStoreConfigQuery, {
1713
fetchPolicy: 'cache-and-network'
1814
});

packages/peregrine/lib/talons/App/__tests__/useApp.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ useHistory.mockImplementation(() => ({
1616
go: reload
1717
}));
1818

19+
jest.mock(
20+
'@magento/peregrine/lib/hooks/useCustomerWishlistSkus/useCustomerWishlistSkus',
21+
() => ({
22+
useCustomerWishlistSkus: jest.fn()
23+
})
24+
);
25+
1926
jest.mock('@magento/peregrine/lib/context/app', () => {
2027
const state = {
2128
drawerClosed: false,

packages/peregrine/lib/talons/App/useApp.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo } from 'react';
22
import { useHistory } from 'react-router-dom';
33

44
import errorRecord from '@magento/peregrine/lib/util/createErrorRecord';
5+
import { useCustomerWishlistSkus } from '@magento/peregrine/lib/hooks/useCustomerWishlistSkus/useCustomerWishlistSkus';
56
import { useAppContext } from '@magento/peregrine/lib/context/app';
67

78
const dismissers = new WeakMap();
@@ -41,6 +42,8 @@ export const useApp = props => {
4142
} = props;
4243
const history = useHistory();
4344

45+
useCustomerWishlistSkus();
46+
4447
const reload = useCallback(() => {
4548
if (process.env.NODE_ENV !== 'development') {
4649
history.go(0);

packages/peregrine/lib/talons/Gallery/__tests__/useGallery.spec.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ import defaultOperations from '../gallery.gql';
1515
import mosOperations from '../gallery.gql.ce';
1616
import acOperations from '../gallery.gql.ee';
1717

18-
jest.mock(
19-
'../../../hooks/useCustomerWishlistSkus/useCustomerWishlistSkus',
20-
() => ({
21-
useCustomerWishlistSkus: jest.fn()
22-
})
23-
);
24-
2518
const cache = new InMemoryCache({
2619
typePolicies
2720
});

packages/peregrine/lib/talons/Gallery/useGallery.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { useQuery } from '@apollo/client';
22

3-
import { useCustomerWishlistSkus } from '../../hooks/useCustomerWishlistSkus/useCustomerWishlistSkus';
4-
53
import mergeOperations from '../../util/shallowMerge';
64
import defaultOperations from './gallery.gql';
75

86
export const useGallery = (props = {}) => {
97
const operations = mergeOperations(defaultOperations, props.operations);
108

11-
useCustomerWishlistSkus();
12-
139
const { data: storeConfigData } = useQuery(operations.getStoreConfigQuery, {
1410
fetchPolicy: 'cache-and-network'
1511
});

0 commit comments

Comments
 (0)