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:
parent
4b6f3cae7e
commit
02f42ded18
|
@ -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();
|
||||
} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue