Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 78a4520

Browse files
authored
Dispatch the wc-blocks_render_blocks_frontend event when rendering the empty cart block (#10619)
1 parent dad4e8d commit 78a4520

File tree

1 file changed

+4
-1
lines changed
  • assets/js/blocks/cart/inner-blocks/empty-cart-block

1 file changed

+4
-1
lines changed

assets/js/blocks/cart/inner-blocks/empty-cart-block/frontend.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ const FrontendBlock = ( {
1919
} ): JSX.Element | null => {
2020
const { cartItems, cartIsLoading } = useStoreCart();
2121
useEffect( () => {
22+
if ( cartItems.length !== 0 || cartIsLoading ) {
23+
return;
24+
}
2225
dispatchEvent( 'wc-blocks_render_blocks_frontend', {
2326
element: document.body.querySelector(
2427
'.wp-block-woocommerce-cart'
2528
),
2629
} );
27-
}, [] );
30+
}, [ cartIsLoading, cartItems ] );
2831
if ( ! cartIsLoading && cartItems.length === 0 ) {
2932
return <div className={ className }>{ children }</div>;
3033
}

0 commit comments

Comments
 (0)