-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Dashboard Performance: HtmlContent improvements #4726
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,9 +94,11 @@ function VisualizationWidgetHeader({ widget, refreshStartedAt, parameters, onPar | |
<p> | ||
<QueryLink query={widget.getQuery()} visualization={widget.visualization} readOnly={!canViewQuery} /> | ||
</p> | ||
<HtmlContent className="text-muted markdown query--description"> | ||
{markdown.toHTML(widget.getQuery().description || "")} | ||
</HtmlContent> | ||
{!isEmpty(widget.getQuery().description) && ( | ||
<HtmlContent className="text-muted markdown query--description"> | ||
{markdown.toHTML(widget.getQuery().description || "")} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't cache it with |
||
</HtmlContent> | ||
)} | ||
</div> | ||
</div> | ||
{!isEmpty(parameters) && ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried to use
useMemo
instead ofReact.memo
?React.memo
changes behavior of component (due to shallow comparison of props, component may not properly react to props changes):There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
useMemo
should have the same performance in concept, but not re-rendering the component at all looked better. For theHtmlContent
component it should be totally dependent on its props. I quickly checked its usages, it has only an string for className (basic variable types don't create issues with shallow comparison) and thechildren
node didn't seem a problem as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation! While I personally prefer
useMemo
,React.memo
looks good as well 👍