Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!