🐛 Check if cancel is possible before calling it

This commit is contained in:
Philipp Stracker 2024-09-17 14:31:21 +02:00
parent 119fdec839
commit 85ad2f8edb
No known key found for this signature in database

View file

@ -69,7 +69,9 @@ export const usePhoneSyncHandler = ( paymentComponent ) => {
// Cleanup on unmount, canceling any pending debounced calls.
useEffect( () => {
return () => {
debouncedUpdatePhone.cancel();
if ( debouncedUpdatePhone?.cancel ) {
debouncedUpdatePhone.cancel();
}
};
}, [ debouncedUpdatePhone ] );
};