Optimize for prop drilling

This commit is contained in:
Daniel Dudzic 2024-09-13 23:09:51 +02:00
parent f77aae6b90
commit 859fd3396b
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
6 changed files with 28 additions and 43 deletions

View file

@ -1,12 +1,10 @@
import { useCallback } from '@wordpress/element';
import { useAddressEditing } from './useAddressEditing';
import useCustomerData from './useCustomerData';
export const useShippingAddressChange = (
fastlaneSdk,
setShippingAddress,
setWooShippingAddress
) => {
export const useShippingAddressChange = ( fastlaneSdk, setShippingAddress ) => {
const { setShippingAddressEditing } = useAddressEditing();
const { setShippingAddress: setWooShippingAddress } = useCustomerData();
return useCallback( async () => {
if ( fastlaneSdk ) {
@ -14,10 +12,6 @@ export const useShippingAddressChange = (
await fastlaneSdk.profile.showShippingAddressSelector();
if ( selectionChanged ) {
setShippingAddress( selectedAddress );
console.log(
'Selected shipping address changed:',
selectedAddress
);
const { address, name, phoneNumber } = selectedAddress;