-
Notifications
You must be signed in to change notification settings - Fork 191
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
wrong message when useMemo re-renders #68
Comments
removed useMemo from being concidered as a reason for re-renders |
Can you confirm this issue? Should this ticket re-opened? @vzaidman |
are you using the latest version? |
@Hypnosphi hey! |
I use v4.3.2, the useMemo is used inside own custom hook, and the custom hook is not tracked by wdyr. |
@vzaidman because we will most likely pass it as a prop after all |
But I agree that those shouldn't be considered reasons for rerender of the component that uses them. I think we can only update |
To be fair, |
OK! I just wanted to make sure. |
@Hypnosphi now i also see that
saves the deps of the hook per hook result. but if a hook simply returns an object that was created anywhere else it might create false positives. for this reason I will only keep useCallback and remove useMemo from participating in it's rare to return functions from useMemo anyway... |
not so rare: const throttledCallback = useMemo(() => throttle(callback, timeout), [callback, timeout]) Please don't break this usecase. What are usecases for returning a function created somewhere else by the way? Why does one even need |
Also, |
gotcha i'll keep it inside. By the way the throttle example is an anti pattern based on React docs:
|
What is the recommended way to do that? |
i think
|
What if both |
Probably a longer and uglier hook using useRef... |
this guy built a whole library around it: |
@Code-guru @Hypnosphi |
i'll release version 5 very soon. |
In the following case:
when the hook
useMemo
re-creates obj even if it's deps deep equals, the message says A was re-rendered because if it, where in reality useMemo re-generatedobj
without a reason, but A is not re-rendered because of this.The text was updated successfully, but these errors were encountered: