Skip to content

Instantly share code, notes, and snippets.

@geetotes
Last active April 30, 2017 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geetotes/21ba43b696645059566ad1c70d4d1b4f to your computer and use it in GitHub Desktop.
Save geetotes/21ba43b696645059566ad1c70d4d1b4f to your computer and use it in GitHub Desktop.
class BasicWizard extends React.Component {
/*
snip...
*/
_next(data) {
// data is the user input from the form
// it could be saved here in state or POSTed to an API, for example
// after that is done, we'll move currentStep forward
// look familiar?
let currentStep = this.state.currentStep;
if (currentStep >= 2) {
currentStep = 3;
} else {
currentStep = currentStep + 1;
}
this.setState({
currentStep: currentStep
});
}
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