Prevent infinite loop when initialising the payments data store in the editor. (https://github.com/woocommerce/woocommerce-blocks/pull/7256)

* Unsubscribe the editor from changes when store is initialised

* Use correct action to initialize payment store
This commit is contained in:
Thomas Roberts 2022-10-07 09:41:44 -07:00 committed by GitHub
parent 4b6f3cae7e
commit 02f42ded18
1 changed files with 2 additions and 2 deletions

View File

@ -36,14 +36,14 @@ const isEditor = !! wpDataSelect( 'core/editor' );
// This is needed to ensure that the payment methods are displayed in the editor
if ( isEditor ) {
subscribe( async () => {
const unsubscribeEditor = subscribe( async () => {
await checkPaymentMethodsCanPay();
await checkPaymentMethodsCanPay( true );
} );
const unsubscribeInitializePaymentStore = subscribe( async () => {
wpDataDispatch( 'wc/store/payment' ).__internalInitializePaymentStore();
unsubscribeEditor();
unsubscribeInitializePaymentStore();
} );
}