From ae86bafe05b70767a8f77f6c9b1a42e4697d2c1e Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Thu, 16 Dec 2021 10:30:23 +0000 Subject: [PATCH] Fix extra network request on cart (#5394) --- .../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 );