diff --git a/assets/js/base/context/cart-checkout/checkout/index.js b/assets/js/base/context/cart-checkout/checkout/index.js index ef55f0654de..0a7c95a3afd 100644 --- a/assets/js/base/context/cart-checkout/checkout/index.js +++ b/assets/js/base/context/cart-checkout/checkout/index.js @@ -93,7 +93,7 @@ const CheckoutProvider = ( { // the redirectUrl for when checkout is reset to PRISTINE state. DEFAULT_STATE.redirectUrl = redirectUrl; const [ checkoutState, dispatch ] = useReducer( reducer, DEFAULT_STATE ); - const [ observers, subscriber ] = useReducer( emitReducer ); + const [ observers, subscriber ] = useReducer( emitReducer, {} ); const currentObservers = useRef( observers ); // set observers on ref so it's always current useEffect( () => { diff --git a/assets/js/base/context/cart-checkout/shipping/shipping-data-context.js b/assets/js/base/context/cart-checkout/shipping/shipping-data-context.js index 2f200b9a25f..5acb978e0be 100644 --- a/assets/js/base/context/cart-checkout/shipping/shipping-data-context.js +++ b/assets/js/base/context/cart-checkout/shipping/shipping-data-context.js @@ -84,7 +84,7 @@ export const ShippingMethodDataProvider = ( { children } ) => { errorStatusReducer, NONE ); - const [ observers, subscriber ] = useReducer( emitReducer ); + const [ observers, subscriber ] = useReducer( emitReducer, {} ); const [ currentShippingAddress, setAddressState ] = useState( DEFAULT_SHIPPING_ADDRESS ); @@ -140,7 +140,7 @@ export const ShippingMethodDataProvider = ( { children } ) => { ); } else if ( ! shippingOptionsLoading && shippingOptions ) { emitEvent( - currentObservers.observers, + currentObservers.current, EMIT_TYPES.SHIPPING_RATES_SUCCESS, shippingOptions );