fix: resolve react warning when updating state during render in SettingsPublicDomainsListCard (#16700)
Closes #15154
This commit is contained in:
+14
-17
@@ -1,21 +1,14 @@
|
||||
import { SettingsCard } from '@/settings/components/SettingsCard';
|
||||
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
||||
import { SettingPublicDomainRowDropdownMenu } from '@/settings/domains/components/SettingPublicDomainRowDropdownMenu';
|
||||
import { selectedPublicDomainState } from '@/settings/domains/states/selectedPublicDomainState';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { SettingsPath } from 'twenty-shared/types';
|
||||
import { IconAt, IconMailCog, Status } from 'twenty-ui/display';
|
||||
import { useFindManyPublicDomainsQuery } from '~/generated-metadata/graphql';
|
||||
import { SettingsListCard } from '@/settings/components/SettingsListCard';
|
||||
import { type PublicDomain } from '~/generated/graphql';
|
||||
import { SettingPublicDomainRowDropdownMenu } from '@/settings/domains/components/SettingPublicDomainRowDropdownMenu';
|
||||
import { selectedPublicDomainState } from '@/settings/domains/states/selectedPublicDomainState';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
|
||||
import { getSettingsPath } from 'twenty-shared/utils';
|
||||
import { SettingsCard } from '@/settings/components/SettingsCard';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { Link } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
const StyledLink = styled(Link)`
|
||||
text-decoration: none;
|
||||
`;
|
||||
|
||||
export const SettingsPublicDomainsListCard = () => {
|
||||
const navigate = useNavigateSettings();
|
||||
@@ -33,11 +26,15 @@ export const SettingsPublicDomainsListCard = () => {
|
||||
}
|
||||
|
||||
if (publicDomains.length === 0) {
|
||||
setSelectedPublicDomain(undefined);
|
||||
return (
|
||||
<StyledLink to={getSettingsPath(SettingsPath.PublicDomain)}>
|
||||
<SettingsCard title={t`Add Public Domain`} Icon={<IconMailCog />} />
|
||||
</StyledLink>
|
||||
<SettingsCard
|
||||
title={t`Add Public Domain`}
|
||||
Icon={<IconMailCog />}
|
||||
onClick={() => {
|
||||
setSelectedPublicDomain(undefined);
|
||||
navigate(SettingsPath.PublicDomain);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user