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
This rule is not always applicable - functions cannot be hoisted if they depend on (capture) any other variable. If they are not wrapped in useCallback, they will not be stable.
In this example, handleSnapshot must be wrapped in useCallback to be stable, but it cannot be hoisted out of the function because it uses setShowSnapshot. I could add setShowSnapshot to the dependencies list, but it's a known-stable reference (from useState) and thus doesn't need to be provided.
The text was updated successfully, but these errors were encountered:
This rule is not always applicable - functions cannot be hoisted if they depend on (capture) any other variable. If they are not wrapped in
useCallback
, they will not be stable.Example
In this example,
handleSnapshot
must be wrapped inuseCallback
to be stable, but it cannot be hoisted out of the function because it usessetShowSnapshot
. I could addsetShowSnapshot
to the dependencies list, but it's a known-stable reference (fromuseState
) and thus doesn't need to be provided.The text was updated successfully, but these errors were encountered: