The Call Kent Podcast

Best way to reset a form


Listen Later

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!

  • Updated code sandbox
...more
View all episodesView all episodes
Download on the App Store

The Call Kent PodcastBy Kent C. Dodds

  • 5
  • 5
  • 5
  • 5
  • 5

5

2 ratings


More shows like The Call Kent Podcast

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

288 Listeners

Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

Syntax - Tasty Web Development Treats

990 Listeners

PodRocket by LogRocket

PodRocket

61 Listeners