Skip to content

Commit

Permalink
task: Remove deprecated usage of defaultProps for functional components
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia committed Jan 24, 2025
1 parent 6293f02 commit b8ab805
Show file tree
Hide file tree
Showing 23 changed files with 28 additions and 133 deletions.
4 changes: 1 addition & 3 deletions src/components/CommonLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface UpdateInstitutionProfileProperties {
}

function UpdateInstitutionProfile({
isCallToAction,
isCallToAction = false,
className = 'font-normal',
}: UpdateInstitutionProfileProperties): ReactElement {
const { lei } = useParams();
Expand All @@ -44,8 +44,6 @@ function UpdateInstitutionProfile({
);
}

UpdateInstitutionProfile.defaultProps = { isCallToAction: false };

interface UpdateFilingDetailsProperties {
// eslint-disable-next-line react/require-default-props
label?: string;
Expand Down
19 changes: 5 additions & 14 deletions src/components/FormButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,13 @@ interface FormButtonGroupProperties {

function FormButtonGroup({
className,
isFilingStep,
isFilingStep = false,
children,
}: FormButtonGroupProperties & JSX.IntrinsicElements['div']): JSX.Element {
return (
<div
className={`mt-[1.875rem] flex ${
isFilingStep ? 'gap-[1.125rem]' : 'gap-[0.625rem]'
} ${className}`}
>
{children}
</div>
);
const classnames = ['mt-[1.875rem]'];
classnames.push(isFilingStep ? 'gap-[1.125rem]' : 'gap-[0.625rem]');
if (className) classnames.push(className);
return <div className={classnames.join(' ')}>{children}</div>;
}

FormButtonGroup.defaultProps = {
isFilingStep: false,
};

export default FormButtonGroup;
8 changes: 1 addition & 7 deletions src/components/FormErrorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function FormErrorHeader<
M extends FieldValues,
T extends Record<string, string>,
>({
alertHeading,
alertHeading = 'There was a problem completing your user profile',
errors,
id,
keyLogicFunc,
Expand Down Expand Up @@ -120,10 +120,4 @@ function FormErrorHeader<
);
}

FormErrorHeader.defaultProps = {
alertHeading: 'There was a problem completing your user profile',
errors: null,
showKeyIndexNumber: false,
};

export default FormErrorHeader;
6 changes: 1 addition & 5 deletions src/components/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface FormWrapperProperties {

function FormWrapper({
children,
isMarginTop,
isMarginTop = true,
}: FormWrapperProperties): JSX.Element {
const marginTop = isMarginTop ? 'mt-[2.8125rem]' : '';
return (
Expand All @@ -19,8 +19,4 @@ function FormWrapper({
);
}

FormWrapper.defaultProps = {
isMarginTop: true,
};

export default FormWrapper;
4 changes: 0 additions & 4 deletions src/components/GovBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ export default function GovBanner(): JSX.Element {
/>
);
}

GovBanner.defaultProps = {
currentLanguage: 'en',
};
6 changes: 1 addition & 5 deletions src/components/InputErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface InputErrorMessageProperties {

function InputErrorMessage({
children,
status,
status = 'error',
}: InputErrorMessageProperties): JSX.Element {
return (
<div className='mt-[0.9375rem] max-w-[41.875rem]'>
Expand All @@ -21,8 +21,4 @@ function InputErrorMessage({
);
}

InputErrorMessage.defaultProps = {
status: 'error',
};

export default InputErrorMessage;
2 changes: 0 additions & 2 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useHeaderAuthLinks } from 'utils/useHeaderAuthLinks';
import FooterCfGovWrapper from './FooterCfGovWrapper';

export interface LoadingType {
// TODO: Do we need this rule? Adding Loading.defaultProps = {...} does not fix the error.
// eslint-disable-next-line react/require-default-props
message?: ReactElement | string;
}

Expand Down
6 changes: 0 additions & 6 deletions src/components/RadioButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,4 @@ function RadioButtonGroup({
);
}

RadioButtonGroup.defaultProps = {
id: 'radio-button-group',
label: 'Radio Group',
onChange: undefined,
};

export default RadioButtonGroup;
4 changes: 0 additions & 4 deletions src/pages/Filing/FilingApp/FieldEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,4 @@ function FieldEntry({
);
}

FieldEntry.defaultProps = {
isWarning: false,
};

export default FieldEntry;
9 changes: 2 additions & 7 deletions src/pages/Filing/FilingApp/FieldSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ interface FieldProperties {
function FieldSummary({
heading,
fieldArray,
bottomMargin,
bottomMargin = false,
children,
id,
className = '',
lei,
submissionId,
filingPeriod,
isWarning,
isWarning = false,
}: FieldProperties & JSX.IntrinsicElements['div']): JSX.Element {
return (
<div
Expand All @@ -46,9 +46,4 @@ function FieldSummary({
);
}

FieldSummary.defaultProps = {
bottomMargin: false,
isWarning: false,
};

export default FieldSummary;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface FilingErrorsWarningsLimitProperties {
}

function FilingErrorsWarningsLimit({
isWarning,
isWarning = false,
}: FilingErrorsWarningsLimitProperties): JSX.Element {
return (
<div className='my-[1.875rem] max-w-[41.875rem]'>
Expand All @@ -52,8 +52,4 @@ function FilingErrorsWarningsLimit({
);
}

FilingErrorsWarningsLimit.defaultProps = {
isWarning: false,
};

export default FilingErrorsWarningsLimit;
9 changes: 3 additions & 6 deletions src/pages/Filing/FilingApp/InstitutionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,12 @@ function InstitutionCardDataWrapper({
*/
export function InstitutionCard({
lei,
name = '<NO NAME>',
status = '<NO STATUS>',
...others
}: InstitutionDataType): JSXElement {
if (!lei) return null;
return <InstitutionCardDataWrapper {...{ lei, ...others }} />;
return <InstitutionCardDataWrapper {...{ lei, name, status, ...others }} />;
}

InstitutionCard.defaultProps = {
name: '<NO NAME>',
status: '<NO STATUS>',
};

export default InstitutionCard;
6 changes: 1 addition & 5 deletions src/pages/Filing/ProcessStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ProcessStepProperties {

export default function ProcessStep({
number,
size,
size = 'h4',
heading,
children,
}: ProcessStepNumberProperties & ProcessStepProperties): JSX.Element {
Expand All @@ -24,7 +24,3 @@ export default function ProcessStep({
</div>
);
}

ProcessStep.defaultProps = {
...ProcessStepNumber.defaultProps,
};
7 changes: 1 addition & 6 deletions src/pages/Filing/ProcessStepNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ProcessStepNumberProperties {
export function ProcessStepNumber({
number,
withBg,
size,
size = 'h4',
}: ProcessStepNumberProperties): ReactElement {
const StepIcons: Record<number | string, string> = {
'1': 'one',
Expand All @@ -39,8 +39,3 @@ export function ProcessStepNumber({
<Icon name={name} size={size} ariaLabel={`Step ${StepIcons[number]}`} />
);
}

ProcessStepNumber.defaultProps = {
size: 'h4',
withBg: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const parentRssd = 'parent_rssd_id';
const topHolderRssd = 'top_holder_rssd_id';

function UpdateAffiliateInformation({
heading,
heading = 'Update your financial institution affiliate information',
register,
formErrors,
watch,
Expand Down Expand Up @@ -121,8 +121,4 @@ function UpdateAffiliateInformation({
);
}

UpdateAffiliateInformation.defaultProps = {
heading: 'Update your financial institution affiliate information',
};

export default UpdateAffiliateInformation;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface InstitutionApiErrorWrapperType {

// Shared page-level alert for Institution API errors
export function AlertInstitutionApiUnreachable({
isError,
isError = false,
children,
}: InstitutionApiErrorWrapperType): JSX.Element {
if (isError)
Expand All @@ -31,8 +31,4 @@ export function AlertInstitutionApiUnreachable({
return <>{children}</>;
}

AlertInstitutionApiUnreachable.defaultProps = {
isError: false,
};

export default AlertInstitutionApiUnreachable;
12 changes: 2 additions & 10 deletions src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export function DisplayField({
label,
value,
className,
fallbackValue,
alertStatus,
fallbackValue = NOT_APPLICABLE,
alertStatus = 'warning',
}: DisplayFieldProperties): JSX.Element {
// This is needed otherwise a falsy value will only fallback if value is null or undefined
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -83,11 +83,3 @@ export function DisplayField({
</div>
);
}

DisplayField.defaultProps = {
alertStatus: 'warning',
className: undefined,
fallbackValue: NOT_APPLICABLE,
label: undefined,
value: undefined,
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const defaultDescription = (

export function FinancialInstitutionDetails({
data = {} as InstitutionDetailsApiType,
heading,
heading = 'Financial institution details',
isDomainsVisible = true,
description = defaultDescription,
alertStatus,
alertStatus = 'warning',
}: {
data: InstitutionDetailsApiType | undefined;
heading?: ReactNode;
Expand Down Expand Up @@ -112,9 +112,4 @@ export function FinancialInstitutionDetails({
);
}

FinancialInstitutionDetails.defaultProps = {
alertStatus: 'warning',
heading: 'Financial institution details',
};

export default FinancialInstitutionDetails;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function IdentifyingInformation({
data = {} as InstitutionDetailsApiType,
heading = 'Financial institution identifying information',
description = defaultDescription,
alertStatus,
alertStatus = 'warning',
}: {
data: InstitutionDetailsApiType | undefined;
heading?: string;
Expand Down Expand Up @@ -94,7 +94,4 @@ export function IdentifyingInformation({
);
}

IdentifyingInformation.defaultProps = {
alertStatus: 'warning',
};
export default IdentifyingInformation;
9 changes: 1 addition & 8 deletions src/pages/FilingDetails/VoluntaryReporterStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Links from 'components/CommonLinks';
import FieldGroup from 'components/FieldGroup';
import InputErrorMessage from 'components/InputErrorMessage';
import SectionIntro from 'components/SectionIntro';
import { RadioButton } from 'design-system-react';
import InputErrorMessage from 'components/InputErrorMessage';
import type { FieldErrors } from 'react-hook-form';
import type { FilingDetailsSchema } from 'types/formTypes';
import RadioButtonGroup from '../../components/RadioButtonGroup';
Expand Down Expand Up @@ -69,11 +69,4 @@ function VoluntaryReporterStatus({
);
}

VoluntaryReporterStatus.defaultProps = {
disabled: false,
formErrors: undefined,
onChange: undefined,
value: undefined,
};

export default VoluntaryReporterStatus;
8 changes: 2 additions & 6 deletions src/pages/FilingDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
VrsFormHeaderErrors,
} from 'components/FormErrorHeader.data';
import FormMain from 'components/FormMain';
import FormParagraph from 'components/FormParagraph';
import InputErrorMessage from 'components/InputErrorMessage';
import { Link } from 'components/Link';
import { LoadingContent } from 'components/Loading';
Expand All @@ -50,12 +51,11 @@ import useFilingStatus from 'utils/useFilingStatus';
import useInstitutionDetails from 'utils/useInstitutionDetails';
import useSubmitPointOfContact from 'utils/useSubmitPointOfContact';
import useSubmitVoluntaryReporterStatus from 'utils/useSubmitVoluntaryReporterStatus';
import VoluntaryReporterStatus from './VoluntaryReporterStatus';
import {
formatPointOfContactObject,
formatVoluntaryReporterStatusObject,
} from './FilingDetailsUtils';
import FormParagraph from 'components/FormParagraph';
import VoluntaryReporterStatus from './VoluntaryReporterStatus';

const defaultValuesPOC = {
isVoluntary: undefined,
Expand Down Expand Up @@ -485,8 +485,4 @@ function FilingDetails(): JSX.Element {
);
}

FilingDetails.defaultProps = {
onSubmit: undefined,
};

export default FilingDetails;
Loading

0 comments on commit b8ab805

Please sign in to comment.