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


##########
superset-frontend/src/dashboard/components/gridComponents/Chart.jsx:
##########
@@ -150,6 +150,9 @@ const Chart = props => {
   const emitCrossFilters = useSelector(
     state => !!state.dashboardInfo.crossFiltersEnabled,
   );
+  const maxRows = useSelector(
+    state => state.dashboardInfo.common.conf.SQL_MAX_ROW,
+  );

Review Comment:
   ### Unmemoized Redux Selector <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The maxRows value is fetched from Redux store on every render without 
memoization.
   
   ###### Why this matters
   Without memoization, this selector will run on every render potentially 
causing unnecessary re-renders of the component and impacting performance, 
especially in a dashboard with many charts.
   
   ###### Suggested change ∙ *Feature Preview*
   Use useMemo to memoize the selector value:
   ```jsx
   const maxRows = useMemo(
     () => useSelector(state => state.dashboardInfo.common.conf.SQL_MAX_ROW),
     []
   );
   ```
   
   
   ###### 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/c0f35e97-e2bc-4ffc-84eb-1c72669ecbf1/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c0f35e97-e2bc-4ffc-84eb-1c72669ecbf1?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/c0f35e97-e2bc-4ffc-84eb-1c72669ecbf1?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/c0f35e97-e2bc-4ffc-84eb-1c72669ecbf1?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c0f35e97-e2bc-4ffc-84eb-1c72669ecbf1)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:4a647976-2670-4506-8197-2587961540f3 -->
   
   
   [](4a647976-2670-4506-8197-2587961540f3)



-- 
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