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

Render from loop #32

Closed
kchupakhin opened this issue May 24, 2019 · 7 comments
Closed

Render from loop #32

kchupakhin opened this issue May 24, 2019 · 7 comments

Comments

@kchupakhin
Copy link

Hello. I faced with some problem. My first step is Select and for each selection value I have config file with steps, because I need to change set of steps when I change select value. So, my render looks like

 <StepWizard
          isHashEnabled
          isLazyMount
          onStepChange={this.onStepChange}
        >
          {this.renderSelect()}
          {steps.map(({ Component, key }) => (
            <Component key={key} hashKey={key} />
          ))}
        </StepWizard>

The problem is that StepWizard think that there are only two steps (Select and second), although config file (steps) contains list of steps. How I can solve it?

@rashisinha
Copy link

Hi @kchupakhin Did you get a solution to this problem?

@kchupakhin
Copy link
Author

Hi @rashisinha, I took code and modified it, also I removed some extra code for me (I needed less functionality)

@rashisinha
Copy link

Ok thanks @kchupakhin , I am trying to create a wrapper on top of this library so that I can use this wizard in multiple components. But I am not able to figure out how to dynamically send steps components for each parent component.

@kchupakhin
Copy link
Author

@rashisinha, problem in my case was that I had to pass stepsList which depends on some select component before. And inside, wizard thought that it has only two children, that why I added inside .flat method when I get children from props. I'm not sure, that we have the same problem. Maybe I didn’t quite understand the explanation of your problem.

@rashisinha
Copy link

@kchupakhin In my case also, the stepList is dynamic and keeps changing depending on user selection. How did you import the components present in stepList in your component as the stepList is dynamic and this list keeps changing.

@luistak
Copy link

luistak commented Feb 27, 2020

Hi there!

In my case, I solved this issue mapping a list of steps into an array than rendering this list inside the StepWizard

// Example component
...

  const dynamicSteps = dynamicStepsList.map((stepy) => (
    <CustomStep
      key={stepy.id}
      data={stepy}
    />
  ));

  const renderSteps = () => {
    return [
      <SomeIntroductionSteps key={`intro-${steps.title}`} />,
      ...dynamicSteps,
    ];
  }

  return (
      <StepWizard>
        {renderSteps()}
      </StepWizard>
  );

@resolritter
Copy link
Collaborator

This workaround should no longer be needed if #76 works out

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

4 participants