mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +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 TopNavigation from '../../../ReusableComponents/TopNavigation';
|
||||
import BusyStateWrapper from '../../../ReusableComponents/BusyStateWrapper';
|
||||
import { useSaveSettings } from '../../../../hooks/useSaveSettings';
|
||||
|
||||
const SettingsNavigation = () => {
|
||||
|
@ -12,11 +11,9 @@ const SettingsNavigation = () => {
|
|||
|
||||
return (
|
||||
<TopNavigation title={ title } exitOnTitleClick={ true }>
|
||||
<BusyStateWrapper>
|
||||
<Button variant="primary" onClick={ persistAll }>
|
||||
{ __( 'Save', 'woocommerce-paypal-payments' ) }
|
||||
</Button>
|
||||
</BusyStateWrapper>
|
||||
<Button variant="primary" onClick={ persistAll }>
|
||||
{ __( 'Save', 'woocommerce-paypal-payments' ) }
|
||||
</Button>
|
||||
</TopNavigation>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { useCallback } from '@wordpress/element';
|
||||
|
||||
import {
|
||||
CommonHooks,
|
||||
PaymentHooks,
|
||||
|
@ -12,7 +14,7 @@ export const useSaveSettings = () => {
|
|||
const { persist: persistSettings } = SettingsHooks.useStore();
|
||||
const { persist: persistStyling } = StylingHooks.useStore();
|
||||
|
||||
const persistAll = () => {
|
||||
const persistAll = useCallback( () => {
|
||||
withActivity(
|
||||
'persist-methods',
|
||||
'Save payment methods',
|
||||
|
@ -28,7 +30,7 @@ export const useSaveSettings = () => {
|
|||
'Save styling details',
|
||||
persistStyling
|
||||
);
|
||||
};
|
||||
}, [ persistPayment, persistSettings, persistStyling, withActivity ] );
|
||||
|
||||
return { persistAll };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue