Hey guys, I want to create a react component with an union type as props :
type NavigationForTestsProps = {
activeLabel: string;
campaignListType: 'test';
activeTestsCount: number;
exclusionGroupLabel: string;
exclusionGroupTestCount: number;
activeTab: NavigationTab;
setActiveTab: (activeTab: NavigationTab) => void;
};
type NavigationForPersonalizationProps = {
activeLabel: string;
campaignListType: 'personalization';
activeTestsCount: number;
exclusionGroupLabel: undefined;
exclusionGroupTestCount: undefined;
activeTab: NavigationTab;
setActiveTab: (activeTab: Exclude<NavigationTab, 'exclusion-group'>) => void;
};
export const Navigation: FC<NavigationForTestsProps | NavigationForPersonalizationProps> = ({
activeLabel,
activeTestsCount,
exclusionGroupLabel,
exclusionGroupTestCount,
activeTab,
setActiveTab,
campaignListType,
}) => {
I want that if campaignListType is 'test', exclusionGroupLabelet exclusionGroupTestCountare defined, for now it works but with
exclusionGroupLabel: undefined;
exclusionGroupTestCount: undefined;
is there another solution for my case?