You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Waqas-Jani
changed the title
React const function getting previous version of state value when calling the function.
Bug: React const function getting previous version of state value when calling the function.
Apr 4, 2024
This is a common pitfall. State values are more of a snapshot. The learning section "State as a snapshot" describes this in more detail. I hope that helps understand the issue better.
React version:
React: 18.2.0
React Dom: 18.2.0
Link to code example:
The current behavior
Getting the old value for example. when try to call onClose function, in that function getting false value
The expected behavior
Should be true value when call onClose function on button click.
The text was updated successfully, but these errors were encountered: