Discover this podcast and so much more

Podcasts are free to enjoy without a subscription. We also offer ebooks, audiobooks, and so much more for just $11.99/month.

Best way to reset a form

Best way to reset a form

FromThe Call Kent Podcast


Best way to reset a form

FromThe Call Kent Podcast

ratings:
Length:
5 minutes
Released:
Dec 7, 2021
Format:
Podcast episode

Description

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"


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


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
Released:
Dec 7, 2021
Format:
Podcast episode

Titles in the series (100)

The Call Kent podcast is a regular podcast where you call in with a question and Kent answers. Call in with your questions right from your web browser with any device at https://kentcdodds.com/call