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

Time:03-26

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>

CodePudding user response:

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.

CodePudding user response:

You need 'onChange' not 'onchange': https://stackblitz.com/edit/react-ehulbm

CodePudding user response:

I'm don't know what is wrong, for this documentation https://es.reactjs.org/docs/forms.html your code is ok. You can share more context about your project or situation?

  • Related