♻️ Minor simplification

This commit is contained in:
Philipp Stracker 2024-09-16 18:27:42 +02:00
parent b05a3e933f
commit 119fdec839
No known key found for this signature in database

View file

@ -56,15 +56,13 @@ export const usePhoneSyncHandler = ( paymentComponent ) => {
// 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( updatePrefills, PHONE_DEBOUNCE_DELAY )
updatePrefills( component, number );
}, PHONE_DEBOUNCE_DELAY )
).current; ).current;
// Invoke debounced function when paymentComponent or phoneNumber changes. // Invoke debounced function when paymentComponent or phoneNumber changes.
useEffect( () => { useEffect( () => {
if ( paymentComponent && phoneNumber ) { if ( paymentComponent && phoneNumber ) {
debouncedUpdatePhone( phoneNumber, paymentComponent ); debouncedUpdatePhone( paymentComponent, phoneNumber );
} }
}, [ debouncedUpdatePhone, paymentComponent, phoneNumber ] ); }, [ debouncedUpdatePhone, paymentComponent, phoneNumber ] );