Skip to content

Commit b69e0d6

Browse files
committed
Wrap parseStatsPeriod in useMemo
1 parent 41ac058 commit b69e0d6

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

static/app/views/projectDetail/projectScoreCards/projectApdexScoreCard.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {useMemo} from 'react';
2+
13
import {Button} from '@sentry/scraps/button';
24
import {Container} from '@sentry/scraps/layout';
35

@@ -38,14 +40,22 @@ const useApdex = (props: Props) => {
3840
const {projects, environments: environments, datetime} = selection;
3941
const {period} = datetime;
4042

41-
const {start: previousStart} = parseStatsPeriod(
42-
getPeriod({period, start: undefined, end: undefined}, {shouldDoublePeriod: true})
43-
.statsPeriod!
43+
const {start: previousStart} = useMemo(
44+
() =>
45+
parseStatsPeriod(
46+
getPeriod({period, start: undefined, end: undefined}, {shouldDoublePeriod: true})
47+
.statsPeriod!
48+
),
49+
[period]
4450
);
4551

46-
const {start: previousEnd} = parseStatsPeriod(
47-
getPeriod({period, start: undefined, end: undefined}, {shouldDoublePeriod: false})
48-
.statsPeriod!
52+
const {start: previousEnd} = useMemo(
53+
() =>
54+
parseStatsPeriod(
55+
getPeriod({period, start: undefined, end: undefined}, {shouldDoublePeriod: false})
56+
.statsPeriod!
57+
),
58+
[period]
4959
);
5060

5161
const commonQuery = {

0 commit comments

Comments
 (0)