How to get rid of memory effect in React?

For example, the component-Vizard (i.e. phased form), it has the state "step", which determines which step of the form shows now. Next:
switch (this.state.step) {
 case "first":
 return <input type="text" name="a" class="form-control" />;
 case "second":
 return <input type="text" name="b" class="form-control" />
}


Everything seems to be working fine but if the first stage forms emerge validation errors (add the class is-invalid to input), this class moves on to the second new input on another stage, although this should not be PreRender. How to avoid this? Or clean it all up manually?
April 4th 20 at 00:59
2 answers
April 4th 20 at 01:01
the keys add
April 4th 20 at 01:03
It's highly recommended not to cut their algorithms process the form, and to use proven solutions like react-final-form or formik. It very much will simplify your life and get rid of tons of crutches and bicycles.
But if it's an academic project, it is necessary to write a crutch. - art.Aufderhar commented on April 4th 20 at 01:06
@Cooper_Kub, I thought so too) I'm Sick of hostility. Tie react-final-form easier and faster. - Xander.Herman33 commented on April 4th 20 at 01:09

Find more questions by tags JavaScriptReact