jcmcneal / react-step-wizard

A modern flexible step wizard component built for React.
MIT License
583 stars 126 forks source link

isHashEnabled sets #undefined #64

Closed johisco closed 3 years ago

johisco commented 4 years ago

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... ?

resolritter commented 4 years ago

The hashKeys are computed upfront when the StepWizard component is constructed

https://github.com/jcmcneal/react-step-wizard/blob/17e80df5a716052c652c1c2651c6dded0a0096a0/src/index.js#L11

https://github.com/jcmcneal/react-step-wizard/blob/17e80df5a716052c652c1c2651c6dded0a0096a0/src/index.js#L43-L45

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.

resolritter commented 3 years ago

Closing due to lack of response