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

116
Views
Reciba notificaciones cuando ref. cambios actuales en React

¿Hay alguna manera de recibir una notificación cuando ref. cambios actuales en React? Como el código de abajo.

 const ref = useRef(0); // pseudo code ref.addCallback((newValue)=> { // notified }); ref.current = 1; // triggers the notification.
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede hacer uso deluseCallback de esta manera:

 const onChange = useCallback(value => { if(value) { // do whatever you want } }, []);

Y pasar la función a la ref ref prop:

 <div ref={onChange}></div>

Tenga en cuenta que esto no activa rerendes todavía. Tendría que establecer el value en un estado.

about 4 years ago · Santiago Trujillo Report

0

Puedes usar una biblioteca como Observable Slim

Aquí hay un ejemplo de cómo lo usarías:

 ObservableSlim.create(ref.current, true, function(changes) { console.log(JSON.stringify(changes)); });
about 4 years ago · Santiago Trujillo 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!