2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
import { useMemo } from 'react' ;
5
- import { useQuery } from '@tanstack/react-query' ;
5
+ import { useQuery , UseQueryOptions } from '@tanstack/react-query' ;
6
6
import ApiGateway from '../../gateways/Api.gateway' ;
7
7
import { Address , Money } from '../../protos/demo' ;
8
8
import { useCurrency } from '../../providers/Currency.provider' ;
@@ -26,10 +26,13 @@ const CartItems = ({ productList, shouldShowPrice = true }: IProps) => {
26
26
zipCode : '94043' ,
27
27
} ;
28
28
29
- const { data : shippingConst = { units : 0 , currencyCode : 'USD' , nanos : 0 } } = useQuery ( [ 'shipping' ,
30
- productList , selectedCurrency , address ] , ( ) =>
31
- ApiGateway . getShippingCost ( productList , selectedCurrency , address )
32
- ) ;
29
+ const queryKey = [ 'shipping' , productList , selectedCurrency , address ] ;
30
+ const queryFn = ( ) => ApiGateway . getShippingCost ( productList , selectedCurrency , address ) ;
31
+ const queryOptions : UseQueryOptions < Money , Error > = {
32
+ queryKey,
33
+ queryFn,
34
+ } ;
35
+ const { data : shippingConst = { units : 0 , currencyCode : 'USD' , nanos : 0 } } = useQuery ( queryOptions ) ;
33
36
34
37
const total = useMemo < Money > ( ( ) => {
35
38
const nanoSum =
0 commit comments