Skip to content

Commit

Permalink
fix(issues): Fix infinite react rerenders in issue list (#59169)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Nov 1, 2023
1 parent 034a5d9 commit eb27bc5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions static/app/components/replays/useReplaysCount.tsx
@@ -1,4 +1,4 @@
import {useCallback, useMemo, useState} from 'react';
import {useCallback, useEffect, useMemo, useState} from 'react';

import {DateString, IssueCategory, Organization} from 'sentry/types';
import {ApiQueryKey, useApiQuery} from 'sentry/utils/queryClient';
Expand Down Expand Up @@ -115,21 +115,22 @@ function useReplaysCount({
}
);

return useMemo(() => {
useEffect(() => {
if (isFetched) {
const merged = {
setLastData(last => ({
...zeroCounts,
...lastData,
...last,
...data,
};
setLastData(merged);
return merged;
}));
}
}, [isFetched, zeroCounts, data]);

return useMemo<CountState>(() => {
return {
...lastData,
...data,
};
}, [isFetched, zeroCounts, lastData, data]);
}, [lastData, data]);
}

function makeReplayCountsQueryKey({
Expand Down

0 comments on commit eb27bc5

Please sign in to comment.