Only render a react component when I on submit from a form

By | July 14, 2018

I’m having trouble wrapping my head around only rendering a component after form data is submitted.

So I have an app that has the basic render:

  <form onSubmit={this.onSubmit.bind(this)}>

The idea is that onSubmit would dump some data into the Results component only at the time of submission.

Now I’ll be honest the app would have values already within its state:

this.state = {
  length : 0,
  timeInSeconds: 0

So, I’d only want it to render or re-render this object when a user clicks the submit button and the onSubmit method executes.

I’m sorry this isn’t clicking for me, but any advice or direction would be awesome!



Leave a Reply

Your email address will not be published. Required fields are marked *