Skip to content

Commit

Permalink
Fix extra network request on cart (woocommerce#5394)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflorisca authored and jonny-bull committed Dec 16, 2021
1 parent 06657d4 commit ae86baf
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions assets/js/base/context/hooks/use-customer-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit ae86baf

Please sign in to comment.