PLAY PODCASTS
Best way to reset a form
Season 2 · Episode 1

Best way to reset a form

Mithi asked this on 2021-11-22

The Call Kent Podcast

December 7, 20215m 27s

Audio is streamed directly from the publisher (media.transistor.fm) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

This is a question about: Improve the Performance of your React Forms

In the example, submitting the form successfully will still retain the current values of the fields.

I want the behavior such that"

  1. when the server response says the form is NOT submitted successfully, then the form field will have the current values that has been inputted by the user
  2. But when the server response says that the form is successfully submitted, then the form fields will be blank again.

What's do you think is the best and most performant (and readable) code to approach this in pure React? The approach which will reduce the amount of unnecessary rerenders of the fields?

Thank you!

Topics

reactformsperformance