kgabryje commented on code in PR #30646: URL: https://github.com/apache/superset/pull/30646#discussion_r1832785172
########## superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx: ########## @@ -85,9 +86,17 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => { const directPathToChild = useSelector<RootState, string[]>( state => state.dashboardState.directPathToChild, ); - const chartIds = useSelector<RootState, number[]>(state => - Object.values(state.charts).map(chart => chart.id), + const isEditMode = useSelector<RootState, boolean>( + state => state.dashboardState.editMode, ); + const charts = useSelector<RootState, Chart[]>(state => Review Comment: We shouldn't return frequently changing objects from `useSelector` if it's avoidable, because every change in any chart will trigger rerender of DashboardContainer. I see that we're using charts array to 1) determine if at least 1 chart is loading, and 2) find rendered chart ids. Instead of returning all charts, we could write 2 selectors for those scenarios: 1) ``` const isAnyChartLoading = useSelector<RootState, boolean>(state => Object.values(state.charts).some(chart => chart.chartStatus === 'loading')); ``` 2) ``` const renderedChartIds = useSelector<RootState, number[]>(state => Object.values(state.charts).filter(chart => chart.chartStatus === 'rendered') .map(chart => chart.id); ``` -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org