mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
⚡️ Memoize payment methods in styling tab
This commit is contained in:
parent
30ff337c06
commit
16ec522830
1 changed files with 9 additions and 5 deletions
|
@ -2,17 +2,21 @@ import { __ } from '@wordpress/i18n';
|
|||
|
||||
import { PaymentHooks, StylingHooks } from '../../../../../../data';
|
||||
import { CheckboxStylingSection } from '../Layout';
|
||||
import { useMemo } from '@wordpress/element';
|
||||
|
||||
const SectionPaymentMethods = ( { location } ) => {
|
||||
const { paymentMethods, setPaymentMethods, choices } =
|
||||
StylingHooks.usePaymentMethodProps( location );
|
||||
|
||||
const { all: allMethods } = PaymentHooks.usePaymentMethods();
|
||||
|
||||
const filteredChoices = choices.filter( ( choice ) => {
|
||||
const methodConfig = allMethods.find( ( i ) => i.id === choice.value );
|
||||
return methodConfig?.enabled;
|
||||
} );
|
||||
const filteredChoices = useMemo( () => {
|
||||
return choices.filter( ( choice ) => {
|
||||
const methodConfig = allMethods.find(
|
||||
( i ) => i.id === choice.value
|
||||
);
|
||||
return methodConfig?.enabled;
|
||||
} );
|
||||
}, [ choices, allMethods ] );
|
||||
|
||||
return (
|
||||
<CheckboxStylingSection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue