mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Try to fix Google Pay in the editor
This commit is contained in:
parent
be6b8a39ec
commit
3171e943ba
12 changed files with 487 additions and 97 deletions
|
@ -0,0 +1,31 @@
|
|||
import { useState, useEffect } from '@wordpress/element';
|
||||
import useGooglepayApiToGenerateButton from '../hooks/useGooglepayApiToGenerateButton';
|
||||
|
||||
const GooglepayButton = ( {
|
||||
namespace,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
googlepayConfig,
|
||||
} ) => {
|
||||
const [ buttonHtml, setButtonHtml ] = useState( '' );
|
||||
const googlepayButton = useGooglepayApiToGenerateButton(
|
||||
namespace,
|
||||
buttonConfig,
|
||||
ppcpConfig,
|
||||
googlepayConfig
|
||||
);
|
||||
|
||||
useEffect( () => {
|
||||
if ( googlepayButton ) {
|
||||
setButtonHtml( googlepayButton.outerHTML );
|
||||
}
|
||||
}, [ googlepayButton ] );
|
||||
|
||||
if ( ! buttonHtml ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div dangerouslySetInnerHTML={ { __html: buttonHtml } } />;
|
||||
};
|
||||
|
||||
export default GooglepayButton;
|
Loading…
Add table
Add a link
Reference in a new issue