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

144
Vistas
React ref and ref.current are returning different values

I got a problem when I can't access real value of a ref created via react useRef hook.

So I have a const st = useRef(state); and inside of it there is an object with some keys and values.

I also have a useEffect hook that updates the reference for st.current.

useEffect(() => {
  st.current = value
}, [value])

So when I am doing a console.log of the st variable it shows me an object with a current key and its value is a real time reference for the object I am putting into st.current and all the values inside are correct.

But when I am trying to console.log the st.current itself it shows me the previous state of the object. And also when I am trying to access any of the variables inside the st.current it returns the previous value :(

This is the code example. Pay your attention on selectedFolders key. It shows different values for the same object. enter image description here

enter image description here

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