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

164
Views
What is the difference between calling a function inside an arrow function on an onClick event? ReactJS

So I'm wondering why when I pass info into functions like this, why I have to make it an arrow function compared to an onClick where I just have the function name without the parenthesis. Does this also have something to do with why not calling the function inside an arrow function will just run the function on render, and then it won't run the function again when the div is clicked?

    return(
        <div className="slider">
            <div onClick={() => arrowClicked(-1)} className="slider-left-arrow slider-arrow"></div>
            <img className="slider-image-initial" alt="not found" src={imageArray[imageArrayPosition]} />
            <div onClick={() => arrowClicked(1)} className="slider-right-arrow slider-arrow"></div>
        </div>
    )

Instead of:

    return(
        <div className="slider">
            <div onClick={arrowClicked(-1)} className="slider-left-arrow slider-arrow"></div>
            <img className="slider-image-initial" alt="not found" src={imageArray[imageArrayPosition]} />
            <div onClick={arrowClicked(1)} className="slider-right-arrow slider-arrow"></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!