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

133
Vistas
How to set value to input field in react

How to set the value to the input field in react. Data is fetching from firebase. I was trying to fetch data from the firebase and then data is populated to the input field. But data is sometimes set to input field sometimes not.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You have to fill your data into a local state using useState. Here is the general idea. Can't go into more details without code example from your side.

For example:

const [value, setValue] = useState('')

Then in your useEffect fetching the data:

useEffect(() => {
   const data = fetch('gettingdata') // replace by the way you get your data
   setValue(data)
 }, []}

Then in your input:

<input value={value} onChange={manageYourValueChange} />
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use the useRef hook to avoid unnecessary rerender:

import {useRef, userEffect} from 'react'

const Test:React.FC = () => {
   const inputRef = useRef(null)

   userEffect(() => {
      const resp = yourAsyncGetData()
      inputRef.current.value = (resp)
   }, [])

   return <input ref={inputRef} />
}

export default Test
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