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

118
Vistas
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
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