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

109
Vistas
Get notified when ref.current changes in React

Is there a way to get notified when ref.current changes in React ? Like the code below.

const ref = useRef(0);

// pseudo code
ref.addCallback((newValue)=> {
  // notified
});

ref.current = 1; // triggers the notification.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You can make use of the useCallback hook like so:

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

And pass the function to the ref ref prop:

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

Note that this does not trigger rerendes yet. You would need to set value to a state.

about 4 years ago · Santiago Trujillo Denunciar

0

You can use a library like Observable Slim

Here is an example of how you would use it:

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