0

I'm trying to learn react and I'm watching react tutorials wherein input tag sometimes contains the value attribute and some other tutorials totally skip mentioning it.

If the code is something like


Const[name, setName]= useState()

return(

<div>

   <input on change=. 
   {(e)=>setName(e.target.value)}
<div/>

What difference does setting the value property do? I've tried initialising the input without mentioning the value property and it works fine.(i.e the setName registers what i type and stores it in name). Can anybody pls explain what's the purpose of value attribute?

Vaikruta
  • 141
  • 8

0 Answers0