From 32bc289439f00ef5c1b1db0f9529c0d617e56fcf Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Wed, 15 Dec 2021 18:25:23 +0000 Subject: [PATCH] Fix extra network request on cart --- .../base/context/hooks/use-customer-data.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/assets/js/base/context/hooks/use-customer-data.ts b/assets/js/base/context/hooks/use-customer-data.ts index 2f7fec296e5..49c0c0e90ba 100644 --- a/assets/js/base/context/hooks/use-customer-data.ts +++ b/assets/js/base/context/hooks/use-customer-data.ts @@ -95,26 +95,6 @@ export const useCustomerData = (): { shippingAddress: initialShippingAddress, } ); - // We only want to update the local state once, otherwise the data on the checkout page gets overwritten - // with the initial state of the addresses here - const [ hasCustomerDataSynced, setHasCustomerDataSynced ] = useState< - boolean - >( false ); - - if ( - ! hasCustomerDataSynced && - shouldUpdateAddressStore( - customerData.shippingAddress, - initialShippingAddress - ) - ) { - setCustomerData( { - billingData: initialBillingAddress, - shippingAddress: initialShippingAddress, - } ); - setHasCustomerDataSynced( true ); - } - // Store values last sent to the server in a ref to avoid requests unless important fields are changed. const previousCustomerData = useRef< CustomerData >( customerData );