diff --git a/components/lib/stepper/Stepper.js b/components/lib/stepper/Stepper.js index 430b46e7a1..e169cbc9c0 100644 --- a/components/lib/stepper/Stepper.js +++ b/components/lib/stepper/Stepper.js @@ -2,7 +2,7 @@ import React from 'react'; import { PrimeReactContext } from '../api/Api'; import { useHandleStyle } from '../componentbase/ComponentBase'; import { CSSTransition } from '../csstransition/CSSTransition'; -import { useMergeProps, useMountEffect } from '../hooks/Hooks'; +import { useMergeProps, useMountEffect, useUpdateEffect } from '../hooks/Hooks'; import { UniqueComponentId, classNames } from '../utils/Utils'; import { StepperBase } from './StepperBase'; import { StepperContent } from './StepperContent'; @@ -29,6 +29,12 @@ export const Stepper = React.memo( } }); + useUpdateEffect(() => { + if (props.activeStep >= 0 && props.activeStep <= stepperPanels().length - 1) { + updateActiveStep(undefined, props.activeStep); + } + }, [props.activeStep]); + const getStepProp = (step, name) => { return step?.props?.[name]; };