Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
¿Cómo puedo obtener valor del evento en reaccionar?

esta es mi función que uso en mi componente de inicio de sesión para que cuando cambie mi correo electrónico cambie su valor

 handleChange =e=>{ //clone let username = {...this.state.username}; //edit username = e.currrentTarget.value; //change state this.setState({username}); }

y llamo a esta función en las siguientes líneas

 <form onSubmit ={this.handleSubmit}> <div className="mb-3"> <label htmlFor="exampleInputEmail1" class="form-label">Email address</label> <input value= {this.state.username} onChange = {this.handleChange} type="email" className="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"/> <div id="emailHelp" className="form-text">We'll never share your email with anyone else.</div> </div>

entonces me sale este error

 Warning: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`. at input at div at form at Login (http://localhost:3000/static/js/main.chunk.js:831:5) at Routes (http://localhost:3000/static/js/vendors~main.chunk.js:33026:5) at main at App (http://localhost:3000/static/js/main.chunk.js:238:5) at Router (http://localhost:3000/static/js/vendors~main.chunk.js:32959:15) at BrowserRouter (http://localhost:3000/static/js/vendors~main.chunk.js:32474:5)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bien, eso no es un error. En este caso, debe usar un componente conectado.

 <input value={this.state.username} onChange={this.handleChange} type="email" className="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" />

Por alguna razón, this.handleChange parece null o undefined .

Muéstranos tu código completo para la depuración. Alternativamente, intente usar:

 <input value={this.state.username} onChange={handleChange} type="email" className="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" />

Además, recuerde que podría haber algunos mensajes de error en caché, así que actualice una vez.

Esto no es un error, es solo una advertencia.

Puede usar e.target.value o lo que esté usando ahora.

 handleChange = e => { // also you're not using it right. // because username is just a string value not an object. // let username = { ...this.state.username }; // it should be: let username = this.state.username; //edit username = e.currrentTarget.value; //change state this.setState({ username }); };

Consulte el bloque de código anterior para obtener comentarios sobre dónde se equivocó.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!