mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
⚡️ Resolve unnecessary re-render of header
This commit is contained in:
parent
023bc277d0
commit
9c1803e8ea
2 changed files with 7 additions and 8 deletions
|
@ -2,7 +2,6 @@ import { Button } from '@wordpress/components';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
import TopNavigation from '../../../ReusableComponents/TopNavigation';
|
import TopNavigation from '../../../ReusableComponents/TopNavigation';
|
||||||
import BusyStateWrapper from '../../../ReusableComponents/BusyStateWrapper';
|
|
||||||
import { useSaveSettings } from '../../../../hooks/useSaveSettings';
|
import { useSaveSettings } from '../../../../hooks/useSaveSettings';
|
||||||
|
|
||||||
const SettingsNavigation = () => {
|
const SettingsNavigation = () => {
|
||||||
|
@ -12,11 +11,9 @@ const SettingsNavigation = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TopNavigation title={ title } exitOnTitleClick={ true }>
|
<TopNavigation title={ title } exitOnTitleClick={ true }>
|
||||||
<BusyStateWrapper>
|
<Button variant="primary" onClick={ persistAll }>
|
||||||
<Button variant="primary" onClick={ persistAll }>
|
{ __( 'Save', 'woocommerce-paypal-payments' ) }
|
||||||
{ __( 'Save', 'woocommerce-paypal-payments' ) }
|
</Button>
|
||||||
</Button>
|
|
||||||
</BusyStateWrapper>
|
|
||||||
</TopNavigation>
|
</TopNavigation>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { useCallback } from '@wordpress/element';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CommonHooks,
|
CommonHooks,
|
||||||
PaymentHooks,
|
PaymentHooks,
|
||||||
|
@ -12,7 +14,7 @@ export const useSaveSettings = () => {
|
||||||
const { persist: persistSettings } = SettingsHooks.useStore();
|
const { persist: persistSettings } = SettingsHooks.useStore();
|
||||||
const { persist: persistStyling } = StylingHooks.useStore();
|
const { persist: persistStyling } = StylingHooks.useStore();
|
||||||
|
|
||||||
const persistAll = () => {
|
const persistAll = useCallback( () => {
|
||||||
withActivity(
|
withActivity(
|
||||||
'persist-methods',
|
'persist-methods',
|
||||||
'Save payment methods',
|
'Save payment methods',
|
||||||
|
@ -28,7 +30,7 @@ export const useSaveSettings = () => {
|
||||||
'Save styling details',
|
'Save styling details',
|
||||||
persistStyling
|
persistStyling
|
||||||
);
|
);
|
||||||
};
|
}, [ persistPayment, persistSettings, persistStyling, withActivity ] );
|
||||||
|
|
||||||
return { persistAll };
|
return { persistAll };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue