Answer the question
In order to leave comments, you need to log in
How to reset a component to its original state?
The component has a form. After a successful submission, the form is replaced div
with a successful submission message. The switch from the form window to the message window occurs when the flag is changed isSubmitted
from false to true .
In addition to the message that the form has been submitted, the user is prompted to either go to another page, or fill out and submit the form again, but with different data.
The question is how to reset the entire component to its original state? So that all inputs are erased, the isSubmitted flag becomes false again, and all other variables return to their default state? Now I do it through the tag<a>
, which directs to the same page. But I don't like the fact that the page is being re-rendered, and especially the fact that it flickers.
In turn, assigning to all variables that are used in the component, their default value also seems to me not the best idea.
What would you suggest in this situation?
Answer the question
In order to leave comments, you need to log in
assigning to all variables that are used in the component, their default value also seems to me not the best idea
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question