devrnt / react-use-wizard

🧙 A React wizard (stepper) builder without the hassle, powered by hooks.

Home Page:https://devrnt.github.io/react-use-wizard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to add or remove steps conditionally?

felipepastor opened this issue · comments

Hi,

Can I add or remove future steps based on a condition? Right now I have the Wizard with a main flow mandatory for everyone, but after the last step of this flow I would like to redirect the user to a different path.
I'm getting a strange behaviour when I try to apply the code bellow, the step is jumping direct to the ConditionStep1 once I update the condition state but don't trigger the nextStep.

Thanks.

const getFlow = () => {
  if(condition) {
    return [<ConditionStep1 />, <ConditionStep2 />]
  }
  
  return [<NormalStep1 />, <NormalStep2 />]
}

return (
    <Wizard>
      <MainStep>
        ...
        {getFlow()}
      </MainStep>
   </Wizard> 
)

This works fine. You can create different paths based on a condition