Skip to content

Commit 72620c6

Browse files
committed
chore: memoize strategies options
1 parent 93c46c6 commit 72620c6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/components/app/details/triggerView/cdMaterial.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useContext, useEffect, useRef, useState } from 'react'
17+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react'
1818
import ReactGA from 'react-ga4'
1919
import { Prompt, useHistory, useLocation } from 'react-router-dom'
2020
import Tippy from '@tippyjs/react'
@@ -339,12 +339,16 @@ const CDMaterial = ({
339339
const showConfigDiffView = searchParams.mode === 'review-config' && searchParams.deploy
340340
const isExceptionUser = materialsResult?.deploymentApprovalInfo?.approvalConfigData?.isExceptionUser ?? false
341341

342-
const pipelineStrategyOptions = (pipelineStrategies ?? []).flatMap(({ error, strategies }) => {
343-
if (error) {
344-
return []
345-
}
346-
return strategies
347-
})
342+
const pipelineStrategyOptions = useMemo(
343+
() =>
344+
(pipelineStrategies ?? []).flatMap(({ error, strategies }) => {
345+
if (error) {
346+
return []
347+
}
348+
return strategies
349+
}),
350+
[pipelineStrategies],
351+
)
348352

349353
const {
350354
pipelineDeploymentConfigLoading,

0 commit comments

Comments
 (0)