mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
🔥 Remove useless state value
This commit is contained in:
parent
c8fd798f62
commit
b05a3e933f
3 changed files with 4 additions and 9 deletions
|
@ -17,8 +17,7 @@ const useAxoSetup = (
|
||||||
paymentComponent,
|
paymentComponent,
|
||||||
onChangeCardButtonClick,
|
onChangeCardButtonClick,
|
||||||
setShippingAddress,
|
setShippingAddress,
|
||||||
setCard,
|
setCard
|
||||||
setWooPhone
|
|
||||||
) => {
|
) => {
|
||||||
const { setIsAxoActive, setIsAxoScriptLoaded } = useDispatch( STORE_NAME );
|
const { setIsAxoActive, setIsAxoScriptLoaded } = useDispatch( STORE_NAME );
|
||||||
const paypalLoaded = usePayPalScript( ppcpConfig );
|
const paypalLoaded = usePayPalScript( ppcpConfig );
|
||||||
|
@ -35,7 +34,7 @@ const useAxoSetup = (
|
||||||
setBillingAddress: setWooBillingAddress,
|
setBillingAddress: setWooBillingAddress,
|
||||||
} = useCustomerData();
|
} = useCustomerData();
|
||||||
|
|
||||||
usePhoneSyncHandler( paymentComponent, setWooPhone );
|
usePhoneSyncHandler( paymentComponent );
|
||||||
|
|
||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
console.log( 'Initializing class toggles' );
|
console.log( 'Initializing class toggles' );
|
||||||
|
|
|
@ -46,10 +46,9 @@ const updatePrefills = ( paymentComponent, phoneNumber ) => {
|
||||||
/**
|
/**
|
||||||
* Custom hook to synchronize the WooCommerce phone number with a React component state.
|
* Custom hook to synchronize the WooCommerce phone number with a React component state.
|
||||||
*
|
*
|
||||||
* @param {Function} setWooPhone - The state setter function for the phone number.
|
|
||||||
* @param {Object} paymentComponent - The CardField component from Fastlane.
|
* @param {Object} paymentComponent - The CardField component from Fastlane.
|
||||||
*/
|
*/
|
||||||
export const usePhoneSyncHandler = ( paymentComponent, setWooPhone ) => {
|
export const usePhoneSyncHandler = ( paymentComponent ) => {
|
||||||
// Fetch and sanitize phone number from WooCommerce.
|
// Fetch and sanitize phone number from WooCommerce.
|
||||||
const phoneNumber = useSelect( ( select ) =>
|
const phoneNumber = useSelect( ( select ) =>
|
||||||
getSanitizedPhoneNumber( select )
|
getSanitizedPhoneNumber( select )
|
||||||
|
@ -58,7 +57,6 @@ export const usePhoneSyncHandler = ( paymentComponent, setWooPhone ) => {
|
||||||
// Create a debounced function that updates the prefilled phone-number.
|
// Create a debounced function that updates the prefilled phone-number.
|
||||||
const debouncedUpdatePhone = useRef(
|
const debouncedUpdatePhone = useRef(
|
||||||
debounce( ( number, component ) => {
|
debounce( ( number, component ) => {
|
||||||
setWooPhone( number );
|
|
||||||
updatePrefills( component, number );
|
updatePrefills( component, number );
|
||||||
}, PHONE_DEBOUNCE_DELAY )
|
}, PHONE_DEBOUNCE_DELAY )
|
||||||
).current;
|
).current;
|
||||||
|
|
|
@ -27,7 +27,6 @@ const Axo = ( props ) => {
|
||||||
const { onPaymentSetup } = eventRegistration;
|
const { onPaymentSetup } = eventRegistration;
|
||||||
const [ shippingAddress, setShippingAddress ] = useState( null );
|
const [ shippingAddress, setShippingAddress ] = useState( null );
|
||||||
const [ card, setCard ] = useState( null );
|
const [ card, setCard ] = useState( null );
|
||||||
const [ wooPhone, setWooPhone ] = useState( '' );
|
|
||||||
const [ paymentComponent, setPaymentComponent ] = useState( null );
|
const [ paymentComponent, setPaymentComponent ] = useState( null );
|
||||||
|
|
||||||
const fastlaneSdk = useFastlaneSdk( axoConfig, ppcpConfig );
|
const fastlaneSdk = useFastlaneSdk( axoConfig, ppcpConfig );
|
||||||
|
@ -46,8 +45,7 @@ const Axo = ( props ) => {
|
||||||
paymentComponent,
|
paymentComponent,
|
||||||
onChangeCardButtonClick,
|
onChangeCardButtonClick,
|
||||||
setShippingAddress,
|
setShippingAddress,
|
||||||
setCard,
|
setCard
|
||||||
setWooPhone
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const { handlePaymentLoad } = usePaymentSetupEffect(
|
const { handlePaymentLoad } = usePaymentSetupEffect(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue