Skip to content

Commit 2b60ac0

Browse files
committed
Memoize Wizard Footer
1 parent 0eee3cd commit 2b60ac0

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

libs/ui-lib/lib/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.tsx

+16-13
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,28 @@ export const ClusterDeploymentDetailsFormWrapper = ({
4141
useFormikContext<ClusterDetailsValues>();
4242
const { t } = useTranslation();
4343

44-
const handleOnNext = () => {
44+
const handleOnNext = React.useCallback(() => {
4545
if (dirty) {
4646
void submitForm();
4747
} else {
4848
void goToNextStep();
4949
}
50-
};
50+
}, [dirty, goToNextStep, submitForm]);
5151

52-
const footer = (
53-
<WizardFooter
54-
activeStep={activeStep}
55-
onNext={handleOnNext}
56-
isNextDisabled={!isValid || isValidating || isSubmitting}
57-
nextButtonProps={{ isLoading: isSubmitting }}
58-
nextButtonText={t('ai:Next')}
59-
onBack={goToPrevStep}
60-
onClose={close}
61-
isBackHidden
62-
/>
52+
const footer = React.useMemo(
53+
() => (
54+
<WizardFooter
55+
activeStep={activeStep}
56+
onNext={handleOnNext}
57+
isNextDisabled={!isValid || isValidating || isSubmitting}
58+
nextButtonProps={{ isLoading: isSubmitting }}
59+
nextButtonText={t('ai:Next')}
60+
onBack={goToPrevStep}
61+
onClose={close}
62+
isBackHidden
63+
/>
64+
),
65+
[activeStep, close, goToPrevStep, handleOnNext, isSubmitting, isValid, isValidating, t],
6366
);
6467

6568
useWizardFooter(footer);

0 commit comments

Comments
 (0)