Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to pass additional props to steps #102

Open
olasunkanmi1 opened this issue Dec 29, 2021 · 1 comment
Open

how to pass additional props to steps #102

olasunkanmi1 opened this issue Dec 29, 2021 · 1 comment

Comments

@olasunkanmi1
Copy link

Is there a way to pass additional props to each steps aside the initial props i.e. previousStep, nextStep e.t.c

@olasunkanmi1 olasunkanmi1 changed the title pops props Dec 29, 2021
@olasunkanmi1 olasunkanmi1 changed the title props how to pass additional props to steps Dec 29, 2021
@MauroG91
Copy link

MauroG91 commented Sep 28, 2022

I hope this helps you.
This is how I implemented where I am working.

const components: any = [ { name: "component-1", component: Component1 }, { name: "component-2", component: Component2 }, { name: "component-3", component: Component3 }, ];

const steps = components.map((component: object, index: number) => { return { ...component, props: { something: ":D" }, }; });

const handleRender = () => { const arrOfComponents = steps.map((step) => createElement(step.component, step?.props) ); const arrOfChildren = Children.toArray(arrOfComponents); return Children.map(arrOfChildren, (child, index) => cloneElement(child as any) ); };

<StepWizard> {handleRender()} </StepWizard>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants