I am trying to do a multistep form, with a final form summarizing information that the user wrote in previous steps before they can submit.
But when I write into inputs, it doesn’t display anything even if the console returns characters.
Here is a link where I reproduced the issue.
What am I doing wrong, is there a better way to do that?
2
Answers
you have to remove ‘value’ from every input element, because value is set to formdata value, it is empty string. turn this
into this
and do the same on every input element
Here is working example.
First of all you need to store your
formData
in state usinguseState
hook. You are using global variable and React wouldn’t re-render the UI unless componentsprops
orstate
.Then you need to change the state, I would like to use single function for every form state.
Then,
PaymentForm
component would be something like this.Then use
onChange
function according to your form components like below.