Skip to content

Instantly share code, notes, and snippets.

@geetotes
Last active April 30, 2017 23:18
Show Gist options
  • Save geetotes/8a37aabf869de80441ae2b6ab99232e2 to your computer and use it in GitHub Desktop.
Save geetotes/8a37aabf869de80441ae2b6ab99232e2 to your computer and use it in GitHub Desktop.
class BasicWizard extends React.Component {
constructor() {
this.state = {
steps: []
currentStep: location.hash //obvs this is an unsafe way to do this -- this example is for conceptual purposes only
};
}
// This keeps the hash updated when the user moves to the next step in the wizard
componentDidUpdate() {
location.hash = this.state.currentStep
}
/*
snip...
*/
render() {
let currentStep = this.state.currentStep;
return(
<div>
<Step1 currentStep={currentStep) afterValid={this._next} />
<Step2 currentStep={currentStep) afterValid={this._next} />
<Step3 currentStep={currentStep) afterValid={this._next} />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment