Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
changing data from context consumer doesn't change the displayed data (React)

I'm implementing a shopping cart, that obviously will have a button to add more products. I implemented the cart context and the functionality works fine, but when I increase the number of the products to purchase it doesn't change the number displayed. What could my issue would be?

Here is my code for the context consumer

    render() {
    return (
        <CartContext.Consumer>
            {
                (cartContext =>{
                    const {addProduct} = cartContext
                        return(
                            <div>
                                <h1 key={this.props.product.itemId}> {this.state.product.name} </h1>
                                <button onClick={() => {addProduct(this.props.product.itemId)}}> Add </button>
                                <h4>{this.props.product.qty}</h4>
                                <hr/>
                            </div>
                        )
                })
            }
        </CartContext.Consumer>
    )
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda