korbit-ai[bot] commented on code in PR #35665:
URL: https://github.com/apache/superset/pull/35665#discussion_r2433463457


##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/HandlebarsRenderer.tsx:
##########
@@ -65,6 +62,10 @@ export const HandlebarsRenderer: 
React.FC<HandlebarsRendererProps> = memo(
     }
 
     if (renderedTemplate || renderedTemplate === '') {
+      const htmlContent = htmlSanitization
+        ? sanitizeHtml(renderedTemplate)
+        : renderedTemplate;

Review Comment:
   ### Unmemoized HTML sanitization on every render <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   HTML sanitization is performed on every render without memoization, causing 
unnecessary recomputation when the component re-renders with the same template 
content.
   
   
   ###### Why this matters
   This leads to redundant sanitization operations that could impact 
performance, especially for complex HTML content or frequent re-renders in 
tooltip scenarios.
   
   ###### Suggested change ∙ *Feature Preview*
   Wrap the sanitization logic in `useMemo` with `renderedTemplate` and 
`htmlSanitization` as dependencies:
   
   ```typescript
   const htmlContent = useMemo(() => {
     return htmlSanitization
       ? sanitizeHtml(renderedTemplate)
       : renderedTemplate;
   }, [renderedTemplate, htmlSanitization]);
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6ab4aa44-e351-4a48-bf27-f255fc36f317/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6ab4aa44-e351-4a48-bf27-f255fc36f317?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6ab4aa44-e351-4a48-bf27-f255fc36f317?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6ab4aa44-e351-4a48-bf27-f255fc36f317?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6ab4aa44-e351-4a48-bf27-f255fc36f317)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:7cb25377-c194-4c13-bc84-0e2e486511a8 -->
   
   
   [](7cb25377-c194-4c13-bc84-0e2e486511a8)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to