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

perf(vx-tooltip): use useCallback in useTooltip #668

Merged
merged 1 commit into from
May 10, 2020

Conversation

williaster
Copy link
Collaborator

🚀 Enhancements

When using useTooltip introduced in #631 I noticed that passing showTooltip or hideTooltip to a child component causes unnecessary and potentially expensive render cascades / child updates even though tooltipLeft, tooltipTop, or tooltipData didn't change.

This should be fixable by using the useCallback hook, where the callbacks are not instantiated each render, and thus PureComponents or React.memoized components should not update unless tooltipLeft, tooltipTop, or tooltipData update.

@kristw @hshoff
cc @ptmx

@williaster williaster force-pushed the chris--useTooltip-perf-fix branch from 34b505a to 810ad95 Compare May 9, 2020 21:05
@williaster williaster merged commit 5e96d2c into master May 10, 2020
@williaster williaster deleted the chris--useTooltip-perf-fix branch May 10, 2020 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants