I am very new to react, so it can become lousy.
I started with the wizard form from https://redux-form.com/7.2.3/examples/wizard/ and tried to submit the form and change the page to the same address.
I mean, submit the form to WizardFormSecondPage and change the page to WizardFormThirdPage to show the values. So far I have managed to submit the form and change the page, but separately, and with all my strength I am trying to connect both events to the same button click.
Perhaps you can check the details using the instructions in and run .state? (Of course, this is syntactically wrong, but just trying to show the idea)
class WizardForm extends Component { constructor(props) { super(props) this.nextPage = this.nextPage.bind(this) this.previousPage = this.previousPage.bind(this) this.state = { page: 1 } } nextPage() { this.setState({ page: this.state.page + 1 }) } previousPage() { this.setState({ page: this.state.page - 1 }) } render() { const { onSubmit } = this.props const { page } = this.state return ( <div> {page === 1 && <WizardFormFirstPage onSubmit={this.nextPage} />} {page === 2 && ( <WizardFormSecondPage previousPage={this.previousPage} if(onSubmit={onSubmit}) { this.nextPage } /> )} {page === 3 && ( <WizardFormThirdPage /> )} </div> ) } } WizardForm.propTypes = { onSubmit: PropTypes.func.isRequired } export default WizardForm
UPDATE: So another idea would be to display the third page from showResults.js , which is called from index.js on <WizardForm onSubmit={showResults} />
import React from "react"; const testField = () => ( <div> <h1>TEST</h1> </div> ); const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); export default (async function showResults(values) { await sleep(500);
By default, showResults returns console.log with the presented field data, now I'm trying to just make a simple div, but without any decent results. Can someone tell showResults where the point is skipped, and what are the best methods for creating the showResults component?
source share