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

114
Views
Best way to run a function of another component in React on button click?

I have a navbar component which has few buttons, I want to run a function in another component (which uses state variables and some refs). I am using Redux as state manager. Currently the way I'm achieving the task is by having a runFunction = 1 in the Redux store and increment this by 1 on button click. In the main component (which has the function), I have wrapped the function with a useEffect with runFunction as dependency, so whenever runFunction changes, my function gets called. Something like this:

useEffect(()=>{ someFunction() }, [runFunction])

Is this the right way to do so ? Is there any better method to achieve this ?

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!