Using controlled input to set the value of my input area, but it occurs that when i use backspace on the input field it doesn’t delete the last character in the object where i am saving the input values.
I have don’t know what to try because i’m entirely new to react.
2
Answers
When using controlled input in React, you need to include two arguments (or attributes) for the input element:
value
andonChange
event to handle the value change event.To define a state for the input element:
and setting the attributes:
If hitting the return key doesn’t delete, it’s because the onChange event is missing.
You must work with inputs using
useState
.If you’re starting out with React and don’t know exactly what to do, you should have your code something like this: