States don't update inside the firebase auth onAuthStateChanged callback #4189
-
|
I use a state inside the firebase auth onAuthStateChanged callback like this The initial state of status is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
@koroman17 Because you've created a closure that captures the value of You might want to read Dan Abramov's post A Complete Guide to |
Beta Was this translation helpful? Give feedback.
@koroman17 Because you've created a closure that captures the value of
statusat the time the function that was created, and thus it can never see any other value.You might want to read Dan Abramov's post A Complete Guide to
useEffectto better understand why this happens.