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

147
Views
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
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!