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

215
Views
React JS - No entiendo lo que está pasando

ingrese la descripción de la imagen aquí

En la imagen dice que se espera que tenga ";", ¿alguien puede explicarlo?

 import React, {useReducer} from 'react'; import CartContext from './cart-context'; const defaultCartState = { items : [], totalAmount : 0 }; const cartReducer = (state, action) = { if (action.type === 'ADD') { const updatedItems = state.items.concat(item); const updatedTotalAmount = state.totalAmount + action.item.price * action.item.amount; return { items : updatedItems, totalAmount : updatedTotalAmount }; } return defaultCartState; } const CartProvider = (props) => { const [cartState, dispatchCartState] = useReducer(cartReducer, defaultCartState); const adder = (item) =>{ dispatchCartState({type : 'ADD', item : item}) }; const remover = (id) => { dispatchCartState({type : 'REMOVE', id : id}) }; const cartContext = { item: [], totalAmount : 0, addItem : adder, removeItem : remover } return ( <CartContext.Provider value={cartContext}> {props.children} </CartContext.Provider> ); } export default CartProvider;

No sé lo que dice el código. Se ha adjuntado una imagen.

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

0

Está utilizando la función de flecha de forma incorrecta

Actualice su función cartReducer de esta manera

 const cartReducer = (state, action) => { if (action.type === 'ADD') { const updatedItems = state.items.concat(item); const updatedTotalAmount = state.totalAmount + action.item.price * action.item.amount; return { items : updatedItems, totalAmount : updatedTotalAmount }; }
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!