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

226
Views
redux reducer... + 1 Creé una nueva matriz y agregué una. Ahora, ¿cómo lo vuelvo a armar y devuelvo el nuevo estado?

Esto casi funciona pero no actualiza la interfaz de usuario... así que encontré el índice de lo que quiero cambiar, creé una nueva matriz newFavorites y aumenté un valor en una de sus claves (conjuntos +1). Pero no estoy seguro de cómo devolver el nuevo estado con el valor clave actualizado.

aquí está el modelo. solo quiero agregar uno a los conjuntos

 class Exercise { constructor(id, name, gifUrl, equipment, sets=4){ this.id = id; this.name = name; this.gifUrl = gifUrl; this.equipment = equipment; this.sets = sets; } } export default Exercise; const initialState = { favoritedExercises: [], } case ADD_SETS: const index= state.favoritedExercises.findIndex(fav => fav.id === action.payload.id); let newFavorites = [...state.favoritedExercises]; newFavorites[index].sets + 1; return { ...state, favoritedExercises: newFavorites }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

para cualquier otra persona que pueda tener este malentendido ...

 case ADD_SETS: const index= state.favoritedExercises.findIndex(fav => fav.id === action.payload.id); let newFavorites = [...state.favoritedExercises]; newFavorites[index].sets = newFavorites[index].sets + 1; console.log(newFavorites[index]) return { ...state, favoritedExercises: newFavorites }
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!