-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: useStateRef #22163
Comments
Is this still an issue? |
are you joking? |
I'm Not. |
Yes this is an issue |
All right.. |
I'm not React Core Team member, you should ask from them |
Alright. |
There's a separate area for RFCs: Seems like this issue should be opened there? |
But we also need to PR for this repo also... |
Thanks, @bvaughn, I couldn't find it, but anyway I will open this issue on there |
Thanks! I'll close this issue then. |
Unfortunately, I couldn't find the best place to ask about that:
I start with an example:
Imagine we have the above code, what is a problem? problem is React runs
useEffect
inside function every timecount
changes, but might we don't need to know updated count's value untilvisibilitychange
event happens.we can have a new hook like this:
and we can change exmaple code to this:
So, we could remove
count
fromuseEffect
dependence anduseEffect
inside function just run onceAlso, this hook is very useful for
useCallback
, please see this exmaple:we can change to
useStateRef
is just a name and we can have a better name for thatThe text was updated successfully, but these errors were encountered: