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
Difference is that we would need to pass function that returns function, but that's it.
It probably couldn't be done by updating current useMemo because useMemo can be used to memoize higher order functions, so difference in callback we pass to it cannot determine whether we want to use it with previous value or not.
If we have this we could skip even more calculations than we are already skipping with useMemo.
Yes, this can be done by adding the same thing to our code, but it would be cool to have this in react.
The text was updated successfully, but these errors were encountered:
I think this hook should be something implemented outside React since usage of this custom hook feels like is niche case and since it looks like it is possible to implement this custom hook without any changes to the React itself.
Sometimes you may need access to previous/last value of useMemo hook. Something similar is available when we set state (useState hook).
Some use case would be:
I am suggesting something like this:
The hook itself would be something like this:
Difference is that we would need to pass function that returns function, but that's it.
It probably couldn't be done by updating current useMemo because useMemo can be used to memoize higher order functions, so difference in callback we pass to it cannot determine whether we want to use it with previous value or not.
If we have this we could skip even more calculations than we are already skipping with useMemo.
Yes, this can be done by adding the same thing to our code, but it would be cool to have this in react.
The text was updated successfully, but these errors were encountered: