-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create a use_memo
hook
#2343
Comments
Yew already has I think we should have some consistency in terms of naming. But I am not sure whether we should make |
@futursolo I don't think use_ref works as you need for your hook users to rerender on value change |
What I am saying is that: So should it follow the |
I think you should not be able to set memo yourself, it would only get updated from changed dependencies. That is the main difference from |
You cannot set React's My suggestion would be:
|
There are cases when you want to put all
use_effect_with_deps
dependencies into the dependency array.Even including all
Callback
s, as it is possible that your callback will become state and is going to have closure into an old state value.But if that callback is created every time you render, that
use_effect_with_deps
is also going to trigger every time.A solution would be to put that
Callback
into ause_memo
hook, like reactuse_memo
oruse_callback
.Here is rough implementation:
The text was updated successfully, but these errors were encountered: