diff --git a/lib/bigcommerce/cart/index.tsx b/lib/bigcommerce/cart/index.tsx index 0d4b9985d..34f70d0ef 100644 --- a/lib/bigcommerce/cart/index.tsx +++ b/lib/bigcommerce/cart/index.tsx @@ -23,7 +23,8 @@ export function extendHook(customFetcher: typeof fetcher) { const useCart = () => { const cart = useCommerceCart( [defaultOpts.url, undefined], - customFetcher + customFetcher, + { revalidateOnFocus: false } ) // Uses a getter to only calculate the prop when required diff --git a/lib/commerce/cart/index.tsx b/lib/commerce/cart/index.tsx index 384fe3aaa..aa152f532 100644 --- a/lib/commerce/cart/index.tsx +++ b/lib/commerce/cart/index.tsx @@ -1,4 +1,4 @@ -import useSWR, { responseInterface } from 'swr' +import useSWR, { responseInterface, ConfigInterface } from 'swr' import Cookies from 'js-cookie' import { HookDeps, HookFetcher } from '../utils/types' import { useCommerce } from '..' @@ -9,16 +9,15 @@ export type CartResponse = responseInterface & { export function useCart( deps: [string | undefined, string | undefined, ...HookDeps[]], - fetcherFn: HookFetcher + fetcherFn: HookFetcher, + swrOptions?: ConfigInterface ) { const { fetcherRef, cartCookie } = useCommerce() const fetcher = (url?: string, query?: string, ...args: HookDeps[]) => Cookies.get(cartCookie) ? fetcherFn({ url, query }, args, fetcherRef.current) : null - const response = useSWR(deps, fetcher, { - revalidateOnFocus: false, - }) + const response = useSWR(deps, fetcher, swrOptions) return Object.assign(response, { isEmpty: true }) as CartResponse }