🔥 Remove useless state value

This commit is contained in:
Philipp Stracker 2024-09-16 17:56:00 +02:00
parent c8fd798f62
commit b05a3e933f
No known key found for this signature in database
3 changed files with 4 additions and 9 deletions

View file

@ -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' );

View file

@ -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;

View file

@ -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(