- I am trying to add the redux form inside my stepper.
- but the problem is if I add form fields inside its reflecting in all the three places.
- so I started debugging the stepper code.
- found that they are iterating in map method.
- so I thought on basis of putting if condition for label I will show the div and form tags.
- but its not working.
- can you tell me how to fix it.
- so that in future I will fix it myself.
- providing my code snippet and sandbox below
https://codesandbox.io/s/y2kjpl343z
return (
<div className={classes.root}>
<Stepper activeStep={activeStep} orientation="vertical">
{steps.map((label, index) => {
console.log("steps---->", steps);
console.log("label---->", label);
console.log("index---->", index);
// if (index === 0) {
if (label === "Select campaign settings") {
return (
<Step key={label}>
<StepLabel>{label}</StepLabel>
<StepContent>
<Typography>{getStepContent(index)}</Typography>
<div className={classes.actionsContainer}>
<div>
<div>test1</div>
<form>here</form>
<Button
disabled={activeStep === 0}
onClick={this.handleBack}
className={classes.button}
>
Back
</Button>
<Button
variant="contained"
color="primary"
onClick={this.handleNext}
className={classes.button}
>
{activeStep === steps.length - 1 ? "Finish" : "Next"}
</Button>
</div>
</div>
</StepContent>
</Step>
);
}
if (label === "Create an ad group") {
return (
<Step key={label}>
<StepLabel>{label}</StepLabel>
<StepContent>
<Typography>{getStepContent(index)}</Typography>
<div className={classes.actionsContainer}>
<div>
<div>test1</div>
<form>here</form>
<Button
disabled={activeStep === 0}
onClick={this.handleBack}
className={classes.button}
>
Back
</Button>
<Button
variant="contained"
color="primary"
onClick={this.handleNext}
className={classes.button}
>
{activeStep === steps.length - 1 ? "Finish" : "Next"}
</Button>
</div>
</div>
</StepContent>
</Step>
);
}
// return (
// <Step key={label}>
// <StepLabel>{label}</StepLabel>
// <StepContent>
// <Typography>{getStepContent(index)}</Typography>
// <div className={classes.actionsContainer}>
// <div>
// <div>test1</div>
// <form>here</form>
// <Button
// disabled={activeStep === 0}
// onClick={this.handleBack}
// className={classes.button}
// >
// Back
// </Button>
// <Button
// variant="contained"
// color="primary"
// onClick={this.handleNext}
// className={classes.button}
// >
// {activeStep === steps.length - 1 ? "Finish" : "Next"}
// </Button>
// </div>
// </div>
// </StepContent>
// </Step>
// );
})}
</Stepper>
{activeStep === steps.length && (
<Paper square elevation={0} className={classes.resetContainer}>
<Typography>All steps completed - you're finished</Typography>
<Button onClick={this.handleReset} className={classes.button}>
Reset
</Button>
</Paper>
)}
</div>
);