1
votes

I m using react and in my project when I delete an item it's input value pass the item that belows it .if I delete last item no problem occurs otherwise deleting an item that's between first-and last item makes problems. I tried so many ways but I m stuck . How can I clear the item's input value that has been deleted so it wont pass the other values.

1
Please see the How to Ask page. There's nothing here anybody could use to help. - Dave Newton

1 Answers

0
votes

If i understood correctly, you need to use useState and set the value to an empty string when the form is submitted

F.e.

const [input,setInput] = useState('');

then in the input you should have something like

onChange=((e)=>{setInput(e.target.value)})

then to submit your form you should have an onSubmit function that does something to your value.The key here is,after you are done,you change the state of your value back to an empty string

onSubmit=((e)=>{
  setInput('')
  e.preventDefault()
})