From 1317595493f44cfa42488272c52c42e51fd2dc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Costa?= Date: Wed, 4 Oct 2023 18:05:23 -0300 Subject: [PATCH 1/2] Use ReactDOM to prevent re-rendering Update import path --- .../woopay-express-checkout-payment-method.js | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/client/checkout/woopay/express-button/woopay-express-checkout-payment-method.js b/client/checkout/woopay/express-button/woopay-express-checkout-payment-method.js index 94637e94988..228032bbf6d 100644 --- a/client/checkout/woopay/express-button/woopay-express-checkout-payment-method.js +++ b/client/checkout/woopay/express-button/woopay-express-checkout-payment-method.js @@ -1,3 +1,9 @@ +/** + * External dependencies + */ +import { useCallback } from 'react'; +import ReactDOM from 'react-dom'; + /** * Internal dependencies */ @@ -18,15 +24,27 @@ const api = new WCPayAPI( request ); +const WooPayExpressCheckoutButtonContainer = () => { + const onRefChange = useCallback( ( node ) => { + if ( node ) { + const root = ReactDOM.createRoot( node ); + + root.render( + + ); + } + }, [] ); + + return ; +}; + const wooPayExpressCheckoutPaymentMethod = () => ( { name: PAYMENT_METHOD_NAME_WOOPAY_EXPRESS_CHECKOUT, - content: ( - - ), + content: , edit: ( Date: Wed, 4 Oct 2023 18:07:54 -0300 Subject: [PATCH 2/2] Add changelog entry --- changelog/fix-7357-multiple-woopay-session-requests | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-7357-multiple-woopay-session-requests diff --git a/changelog/fix-7357-multiple-woopay-session-requests b/changelog/fix-7357-multiple-woopay-session-requests new file mode 100644 index 00000000000..2c2b2d69641 --- /dev/null +++ b/changelog/fix-7357-multiple-woopay-session-requests @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Only request WooPay session data once on blocks pages.