Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
How do i access the value inside the input text box? cant i fetch the value directly from the event variable without using ref?

I am trying to access the value inside the textbox and save it in the state variable. Can i access it without using "ref". Also the statement:

console.log(this.input.value) 

Prints the correct input in the console. But if i do below:

ref ={(input)=>{
this.input = input
console.log(input.value)
}}

I get an error. Please help me understand whats going on in the complete code below.

           <input type="text" 
            className = "form-control form-control-lg"
            placeholder ='0'
            onChange = {async (event)=>{
                const tokenValue = await this.input.value.toString() * 100
                console.log(this.input.value)
                this.setState ({
                    output:tokenValue
                })
                console.log(this.state.output)
            }}
            ref ={(input)=>{this.input = input}}
            required/>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can get input value easily like following

export default function App() {
  const [value, setValue] = useState();

  const handleInputChange = (e) => {
    setValue(e.target.value);
  };

  return (
    <>
      <form>
        <input
          type="text"
          value={value}
          onChange={(e) => handleInputChange(e)}
        />
      </form>
    </>
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda