From 86172fa4d8d2d1772d9a76b8f10267c2cb03afa5 Mon Sep 17 00:00:00 2001 From: YanJin Date: Tue, 21 Nov 2023 18:25:30 +0100 Subject: [PATCH] stepper: group stepnumber and stepProps --- .../components/steppers/Stepper.component.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/components/steppers/Stepper.component.tsx b/src/lib/components/steppers/Stepper.component.tsx index f2a433e72b..8a8744dcae 100644 --- a/src/lib/components/steppers/Stepper.component.tsx +++ b/src/lib/components/steppers/Stepper.component.tsx @@ -55,26 +55,27 @@ export const Stepper = ({ }: { steps: readonly [...Steps]; }) => { - const [currentStep, setCurrentStep] = useState(0); - const [stepProps, setStepProps] = useState>({}); + // const [currentStep, setCurrentStep] = useState(0); + const [stepProps, setStepProps] = useState<{ + step: number; + props: Record; + }>({ step: 0, props: {} }); const next = (props: Record) => { - setCurrentStep(currentStep + 1); - setStepProps(props); + setStepProps({ step: stepProps.step + 1, props }); }; const prev = (props: Record) => { - setCurrentStep(currentStep - 1); - setStepProps(props); + setStepProps({ step: stepProps.step - 1, props }); }; - const { Component } = steps[currentStep]; + const { Component } = steps[stepProps.step]; return ( { return { title: step.label,