react-albus icon indicating copy to clipboard operation
react-albus copied to clipboard

How to switch into specific step on click event from a button in another step

Open rahulgit opened this issue 7 years ago • 1 comments

Is there any option to Switch to a specific step from on click <Steps> <Step id="gandalf"> <h1 className="text-align-center">Gandalf</h1> <button className="btn-fluid margin-1-b" onClick={goTo('dumbledore')} > Go to Dumbledore </button> </Step>

here I need to Switch to dumbledore When clicking Go to Dumbledore

rahulgit avatar Mar 21 '19 06:03 rahulgit

@rahulgit when using Step's render prop, you have access to the router functions. From there, you can use push:

<Steps>
    <Step id="gandalf" render={({ push }) => (
        <>
            <h1 className="text-align-center">Gandalf</h1> 
            <button className="btn-fluid margin-1-b" onClick={() => push('dumbledore')} >Go to Dumbledore</button> 
        </>
    ) /> 
    //Other steps, including 'dumbledore'
</Steps>

You also have access to the push router function from the WithWizard component.

 <WithWizard
     render={({ push }) => ...

See https://github.com/americanexpress/react-albus#contextwizard for more info on what you can use from the wizard context.

jdconner avatar May 21 '19 14:05 jdconner