Need Help with Multi Step Form Submission - specifically handlePreviousStep Function()
Note : My Form is working perfectly fine.Also -> Form is submitting fine.
Problem Description in short : When i click on Previous the data resets and old data goes away
Brief Problem Description :
I have been working on a multi step form.It is working fine and submitting perfectly. I wanted to add a functionality where on clicking previous button i go to previous step and edit the data if i want to , but when i click on previous the data is empty.Added handle Previous , it is working but the data is not flowing backwards.
3 Replies
Code from Parent Page
And if you go back from a previous step to the current step again, you will lose all the data you entered.
It's because you're re-rendering/rendering each step conditionally. So going to the next step will cause the previous one to unmount and thus the data it had will be removed.
I have 2 ideas in mind to fix this:
1- Pass the
projectData
as a prop to each step, and then fill that step's form inputs values based on their name
and the corresponding key
in projectData
.
2- if you're just wanting to make it multi step form mainly for the UX, then I suggest you to use CSS display: none;
to hide the steps, and only display the current step. Maybe add a class of "active" when a step is the current one. I'd do something like:
And then pass that active prop to:
Thanks for Help to Nobody ,,,, i fixed it myself