/** * External dependencies */ import { useCheckoutData, usePaymentEvents, useExpressPaymentMethods, } from '@woocommerce/base-hooks'; import { cloneElement } from '@wordpress/element'; const ExpressPaymentMethods = () => { const [ checkoutData ] = useCheckoutData(); const { dispatch, select } = usePaymentEvents(); // not implementing isInitialized here because it's utilized further // up in the tree for express payment methods. We won't even get here if // there's no payment methods after initialization. const { paymentMethods } = useExpressPaymentMethods(); const paymentMethodSlugs = Object.keys( paymentMethods ); const content = paymentMethodSlugs.length > 0 ? ( paymentMethodSlugs.map( ( slug ) => { const expressPaymentMethod = paymentMethods[ slug ].activeContent; const paymentEvents = { dispatch, select }; return (
  • { cloneElement( expressPaymentMethod, { checkoutData, paymentEvents, } ) }
  • ); } ) ) : (
  • No registered Payment Methods
  • ); return ( ); }; export default ExpressPaymentMethods;