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

175
Views
How to save objects from an array of objects individually in Redux?

I try to send to my Redux state an array of objects and I try to save it in my state.

Redux State:

savedEvents: [],

My array of elements I try to send looks like: [{1},{2}]

My dispatch method :

case 'events/setNewEvent': 
            return { ...state, savedEvents: [...state.savedEvents, action.payload] }; 

If I try to use this 'case', my 'savedEvents' will look like [[{1},{2}]] ant not like [{1},{2}]. Both will be on index 0.

What I have to change in my code to be saved individually, and not together?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You just have to spread the new events in with the ... operator:

return { ...state, savedEvents: [...state.savedEvents, ...action.payload] }; 
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!