Skip to content
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

fix: #2375 tooltip rerenders on hover #3209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

misha-erm
Copy link

@misha-erm misha-erm commented Nov 3, 2024

Description

closes #2375

Every mounted tooltip is re-rendered on hover. This resulted in quite noticeable performance problems as our app has a lot of elements with tooltip

Here are some profiles from our app:
before:
image

after:
image

Since isOpenDelayed is used only in event callbacks replacing it with ref seems like a safe and useful change

Please let me know if anything is missing or more tests with proofs are required

@suitux
Copy link

suitux commented Nov 9, 2024

Do you have plan to merge this? Still happening

@aboveyunhai
Copy link

@chaance Apologize for the tagging.
I believe the usage of useState internally for logical control is a common performance symptom why Radix component is slow. This leads to a lot of unnecessary re-render.
Tooltip is just being one of them.
Hence,
useState => for rendering control. (like {error && <ErrorComponent error.desc />}, the error state or description directly controls the value or display)
useRef => for internal logic state control that has nothing to do with rendering. (like function (){ if (ref.current) {} } )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tooltip] Wrapping the app in TooltipProvider causes every single tooltip to re-render on hover
4 participants