Answer the question
In order to leave comments, you need to log in
Why is there an old value inside the function?
Faced such a problem. After I updated the value of the state in useEffect and after (when clicking on the element) tried to call a callback, then inside this function the value from the state is still null. I also made a log before useEffect, there is a new value. But when calling callback, it's still old. What could be the problem?
PS here I quickly threw in the code for clarity https://pastebin.com/7E66xPB1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question