bito-code-review[bot] commented on PR #41740:
URL: https://github.com/apache/superset/pull/41740#issuecomment-4874668798
<!-- Bito Reply -->
The flagged issue is correct. In `HeadlessAutoRefresh.tsx`, the selector for
`timedRefreshImmuneSlices` returns a new array reference `[]` whenever the
metadata key is missing, causing unnecessary re-renders and resetting the
auto-refresh timer. To resolve this, you can define a stable empty array
outside the component or use `useMemo` to memoize the result.
Here is the corrected implementation for `HeadlessAutoRefresh.tsx`:
```tsx
// Define a stable empty array outside the component
const EMPTY_ARRAY: number[] = [];
const HeadlessAutoRefresh = (): null => {
// ...
const timedRefreshImmuneSlices = useSelector(
(state: RootState) =>
state.dashboardInfo.metadata?.timed_refresh_immune_slices ||
EMPTY_ARRAY,
);
// ...
};
```
I have checked the PR comments, and there are no other actionable
suggestions in the provided context. Would you like me to perform any other
tasks?
**superset-frontend/src/dashboard/components/Header/HeadlessAutoRefresh.tsx**
```
const EMPTY_ARRAY: number[] = [];
const HeadlessAutoRefresh = (): null => {
// ...
const timedRefreshImmuneSlices = useSelector(
(state: RootState) =>
state.dashboardInfo.metadata?.timed_refresh_immune_slices ||
EMPTY_ARRAY,
);
// ...
};
```
--
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]