Axo Block: Make sure the container exists before trying to render the Card component

This commit is contained in:
Daniel Dudzic 2024-10-04 15:13:12 +02:00
parent af9eca7ef6
commit 12fc44eaa7
No known key found for this signature in database
GPG key ID: 31B40D33E3465483

View file

@ -42,8 +42,12 @@ export const Payment = ( { fastlaneSdk, onPaymentLoad } ) => {
const paymentComponent = await fastlaneSdk.FastlaneCardComponent(
{}
);
paymentComponent.render( `#fastlane-card` );
onPaymentLoad( paymentComponent );
// Check if the container exists before rendering
const cardContainer = document.querySelector( '#fastlane-card' );
if ( cardContainer ) {
paymentComponent.render( `#fastlane-card` );
onPaymentLoad( paymentComponent );
}
}
}, [
isGuest,