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

319
Views
How to increase a usestate number inside a div in React.js

I have a useState inside div, I want to update the counter beacuse I want to get another img url from exArr array. is there a way to update counter inside a div?

let exArr = [];
    const [counter, setCounter] = useState(0);

    return (
        <div className="menRight">

            {
                products.filter(product => product.productGender.includes('Kids')).slice(0, showProducts).map(product => (                    
                    <div className="menRightCard">
                        <Link to={`/productBuy?id=${product.productImageFolder}`}>
                            <div className="menRightCardimg">
                                <i className="far fa-heart"></i>
                                <img src={exArr[counter]} alt="" />
  /* I WANT TO CHANGE HERE */   { setCounter(counter => counter + 1) }

                            </div>
                            <div className="menRightCardInfo">
                                <p className="productInfo">
                                    {product.productName}
                                </p>
                                <p className="productPrice">
                                    €{product.productPrice}
                                </p>
                            </div>
                        </Link>
                    </div>

                    
    
    ))
            }       
            <div className="loadMore">
                <button onClick={showMoreItems}>Load More Products</button>
            </div>
        </div>
    );
}
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!