How to change the default value from a text field in react?

Viewed 345

I am not able to edit in the text field its shows only the default value ,how to initially its show the default values and the I have to edit the text field as my requirement

const[vari,setVari]=React.useState("SAM");
  return (
    <div>
    <input value={vari} onchange={(e)=>setVari(e.target.value)}/>
    </div>
2 Answers

It is probably due to the fact that you are spelling the event listener in the HTML way instead of the React way. Try onChange instead of onchange.

Related