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

193
Views
¿Cómo pasar cualquier función anónima a ref y usarla en otro componente de reacción?

Tengo 3 componentes funcionales y me gustaría pasar y manipular datos a través de useRef .
Estoy agregando este método onClose a la propiedad current en uno de mis componentes.

 const onClose = () => { setButtonColor(buttonColor); }; ref.current = { clearSwitchStateOnClose: onClose, };

Estoy llamando a ese método en otro componente.

 ref.current.clearSwitchStateOnClose();

Estoy recibiendo este error,

 Uncaught TypeError: ref.current.clearSwitchStateOnClose is not a function
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Estaba llamando a este método ref.current.clearSwitchStateOnClose(); pero con eso también estaba mutando ref . Supongo que eso estaba causando el problema.
era algo asi,

 ref.current = { showModal: false, modalResponse: null, }; ref.current.clearSwitchStateOnClose();

Después de hacer esto, está funcionando bien.

 ref.current.clearSwitchStateOnClose(); ref.current = { showModal: false, modalResponse: null, };

Perdón por no compartir todo el escenario de esta situación.

about 4 years ago · Juan Pablo Isaza Report
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!