1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: prevent rendering too many hooks error (#8667)

We found an issue where we'd get a minified react error referencing the
LazyProjectExport component.


![image](https://github.com/user-attachments/assets/3cb76315-ccef-4fa6-968c-845ecf21bc0f)


We suspect that the issue might be the conditional rendering of this
component, so the fix is to always render it, but to use the flag to
check whether we should show the count or not.
This commit is contained in:
Thomas Heartman 2024-11-06 12:28:48 +01:00 committed by GitHub
parent 4ed5b1bb8a
commit 3d10887610
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,7 +75,7 @@ interface ITab {
flag?: keyof UiFlags;
new?: boolean;
isEnterprise?: boolean;
label?: () => ReactNode;
labelOverride?: () => ReactNode;
}
const StyledCounterBadge = styled(CounterBadge)(({ theme }) => ({
@ -94,9 +94,14 @@ const TabText = styled('span')(({ theme }) => ({
}));
const ChangeRequestsLabel = () => {
const simplifyProjectOverview = useUiFlag('simplifyProjectOverview');
const projectId = useRequiredPathParam('projectId');
const { total } = useActionableChangeRequests(projectId);
if (!simplifyProjectOverview) {
return 'Change requests';
}
return (
<StyledCounterBadge badgeContent={total ?? 0} color='primary'>
<TabText>Change requests</TabText>
@ -167,7 +172,7 @@ export const Project = () => {
path: `${basePath}/change-requests`,
name: 'change-request',
isEnterprise: true,
label: simplifyProjectOverview ? ChangeRequestsLabel : undefined,
labelOverride: ChangeRequestsLabel,
},
{
title: 'Applications',
@ -319,7 +324,13 @@ export const Project = () => {
<StyledTab
data-loading-project
key={tab.title}
label={tab.label ? tab.label() : tab.title}
label={
tab.labelOverride ? (
<tab.labelOverride />
) : (
tab.title
)
}
value={tab.path}
onClick={() => {
if (tab.title !== 'Flags') {