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

103
Vistas
Losing values from redux object when spreading into new object

I'm fetching data from redux store with useSelector.

const customerProduct = useSelector((state) => state.objects.customersProducts[match.params.customerProductId]);

If I log the data it is displayed like this in the console:

enter image description here

Once I try to use spread operator to create a new object, it would lose all the values with (...).

Like this:

const updatedCustomerProduct = { ...customerProduct, newValue: "abc" };

I would get an output like this:

    const uptdatedCustomerProduct = 
    {
    "id": "AALzgGxtlg",
    "_objCount": 6360,
    "newValue": "abc",
    "className": "customerOfferMetadata"
    }

What's going on here? How could I handle these values? If I copy the object from the console the object is perfectly visible.

Even in redux dev tools the data is displayed like this:

{
    "entityInfo": {
        "productId": 441,
        "bundleOfferId": 22
    },
    "title": {
        "us": "Special Offer"
    },
    "desc": {
        "us": "6 months"
    },
    "order": 0,
    "enabled": true,
    "entityType": "product",
    "detailsUrl": "www.google.com",
    "thumb": {
        "__type": "Pointer",
        "className": "Resource",
        "objectId": "12345"
    },
    "createdAt": "2021-02-26T18:48:25.358Z",
    "updatedAt": "2021-09-21T21:41:49.384Z",
    "clientId": 1,
    "objectId": "AALzgGxtlg"
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm not sure what code is generating those objects for you, but when you see properties in the console that are semitransparent, they are non-enumerable. This means that when applying the spread operator, they are not iterated over, and hence they do not make it into the new object.

To make all properties enumerable, check out the question Make all properties enumerable.

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