jcmcneal/react-step-wizard

isHashEnabled sets #undefined

johisco opened this issue · 2 comments

Im experiencing some issues with the isHashEnable flag where it sets the router browser url to #undefined instead of #step1 ... #step{N} etc...

<StepWizard
                              isHashEnabled={true}
                              transitions={{
                                enterRight: "",
                                enterLeft: "",
                                exitRight: "",
                                exitLeft: "",
                              }}
                            >
                              {this.state.steps.map((stepdata, i) => {
                                return (
                                  <CustomStep
                                    key={i}
                                    data={stepdata}
                                    update={this.setData}
                                    canGoBack={this.canGoBack}
                                  />
                                );
                              })}
                            </StepWizard>

Im using eact-router-dom as my router if that matters... ?

The hashKeys are computed upfront when the StepWizard component is constructed

this.state = this.initialState();

children.forEach((child, i) => {
// Create hashKey map
state.hashKeys[i] = (child.props && child.props.hashKey) || `step${i + 1}`;

I suppose that could happen if your this.state.steps is changing after the first render, because the steps would probably no longer re-hashed, then. This is just a guess, though; I could look into fixing this you provide a minimal reproduction.

Closing due to lack of response