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

516
Vistas
mui TextField in React loosing focus every typing one character after put key props in <div> parent

I have a dynamic component with TextField, but when i put key props in div parent, the TextField always lose focus after typing 1 character, if i delete key props, all normaly. Here my component code.

<div key={uuid()} style={{ display: 'flex', alignItems: 'center', marginBottom: Dimens.px10 }}>
            <TextField
                style={{ marginRight: Dimens.px20 }}
                fullWidth
                required={props.required}
                id="outlined-textarea"
                defaultValue={props.data}
                autoComplete='off'
                label={props.label}
                placeholder={props.label}
                onChange={props.onChange}
            />
            <div style={{
                width: 50,
                maxWidth: 40
            }}>
                <CButton outline isDriver label={<p style={{ fontWeight: 'bold', margin: 0, padding: 0 }}>-</p>} onClick={props.onDeleteClick} />
            </div>
        </div>

How could this happen?

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

0

Keys must be stable, <div key={uuid()}> assigns new key.

If they're not stable then React cannot understand that this might be the same as before and then just re-renders. That is the reason if you remove the the key then all works well.

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