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

150
Views
Reductor que no elimina elementos del estado.

No puedo eliminar elementos del estado redux. Creé una aplicación de pizza y estoy tratando de eliminar artículos del carrito. He implementado con éxito el aumento de la cantidad o la eliminación de todos los artículos en las funciones del carrito. Sin embargo, no puedo implementar una función de eliminación de un elemento en particular. Mi botón en la parte frontal funciona correctamente y pasa la identificación a la función deletePizza que se muestra a continuación

Aquí está mi reductor

 export const cartReducer = (state = [], action) => { switch (action.type) { //Required by next-js-reducer library case HYDRATE: return { ...state, ...action.id }; //Removes all pizza from the cart case 'DELETE_ALL': return [] //Add pizza to cart, if exists increment the pizza case 'ADD_PIZZA': //If pizza is already in the cart const findPizzaIfAdded = state.find(pizza => pizza.id === action.id); if (findPizzaIfAdded !== undefined) { const modifiedQuantity = { ...findPizzaIfAdded, quantity: findPizzaIfAdded.quantity + 1 } return state.map(pizza => pizza.id === action.id ? modifiedQuantity : pizza); } const newPizza = { id: action.id, quantity: 1 } return [ ...state, newPizza ] //I am facing problem here case 'DELETE_PIZZA': return state.filter(pizza => pizza.id !== action.id); default: return state } } // I am using this funcntion to call deletion of pizza, I tried testing if particular function is working. It is successfully working and passing the id export const deletePizza = id => { return { type: 'DELETE_PIZZA', id } }
about 4 years ago · Juan Pablo Isaza
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!