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

294
Views
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
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!