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

173
Vistas
How to edit a property of a object on an array?

I have an array in a useState. and I want to edit a property.

const [equipe_montador, setEquipe_Montador] = useState([]);

<Card title="Adicionar Mão de Obra">
        {equipe_montador.map((item, key) =>
            <div key={key}>
                <InputBox type="number" maxLength={6} title={item.nome} value={item.quantidade} onChange={e => setEquipe_Montador([...equipe_montador, { ...item, quantidade: e.target.value }])} />
            </div>
        )}
    </Card>

But, when I edit the value, the item duplicate.

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

0

I've discovered the solution. It's working, but I don't know if is the best approach. I edit the object and create a new list with the edited object.

        <Card title="Adicionar Mão de Obra">
        {equipe_montador.map((item, key) =>
            <div key={key}>
                <InputBox type="number" maxLength={6} title={item.nome} value={item.quantidade} onChange={e => {
                    var new_array = equipe_montador.map((new_obj) => new_obj.id_objeto === item.id_objeto ?
                        {
                            ...new_obj,
                            quantidade: e.target.value
                        } : new_obj);
                    setEquipe_Montador(new_array);
                }
                } />
            </div>
        )}
    </Card>
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