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(dashboards): Improve "Highlighting" story for TimeSeriesWidgetVisualization #88828

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

gggritso
Copy link
Member

@gggritso gggritso commented Apr 4, 2025

There's a problem in that story! Right now clicking "Highlight Random Sample" doesn't work properly because right after dispatching the "highlight" event to ECharts, it also updates a local state, which re-renders the chart, and the highlight get clobbered. I was going to fix this issue by wrapping the chart in memo, but that's not a proper solution. memo is only a performance optimization, we can't rely on it to maintain uncontrolled chart state for us.

The correct solution is to use useEffect, which is designed for this exact scenario: synchronizing a local React state with something that React doesn't control.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 4, 2025
@gggritso gggritso requested a review from DominikB2014 April 4, 2025 18:33

This comment was marked as outdated.

@gggritso gggritso marked this pull request as ready for review April 4, 2025 19:04
@gggritso gggritso requested a review from a team as a code owner April 4, 2025 19:04
Copy link
Contributor

@DominikB2014 DominikB2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

@gggritso gggritso merged commit e382ebb into master Apr 4, 2025
43 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-166-fix-highlighting-story branch April 4, 2025 19:49
andrewshie-sentry pushed a commit that referenced this pull request Apr 8, 2025
…sualization` (#88828)

There's a problem in that story! Right now clicking "Highlight Random
Sample" doesn't work properly because right after dispatching the
`"highlight"` event to ECharts, it also updates a local state, which
re-renders the chart, and the highlight get clobbered. I was going to
fix this issue by wrapping the chart in `memo`, but that's not a proper
solution. `memo` is _only_ a performance optimization, we can't rely on
it to maintain uncontrolled chart state for us.

The correct solution is to use `useEffect`, which is designed for this
exact scenario: synchronizing a local React state with something that
React doesn't control.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants