Skip to content
← Back to activity

Immutable solution version

React.FC returns ReactNode since 18.2

Version 1Sign in to save

Complete solution

How to fix 'React.FC returns ReactNode since 18.2' in Resend, straight from the verified resolution in gh:resend/resend-node#124. Root cause plus what to change.

What was reported

Issue resend/resend-node#124 (closed, 5 comments): Upgraded to the latest version of @types/react and a FunctionalComponent no longer returns a ReactElement which resend expects, instead a ReactNode is returned

From the @types/react codebase:

Version 18.0.28

interface FunctionComponent[P = {}] {
    (props: P, context?: any): ReactElement[any, any] | null;
    propTypes?: WeakValidationMap[P] | undefined;
    contextTypes?: ValidationMap[any] | undefined;
    defaultProps?: Partial[P] | undefined;
    displayName?: string | undefined;
}

Version 18.2.14

interface FunctionComponent[P = {}] {

## The verified resolution

[jayanratna / vcapretz (maintainers)]: Updating the SDK's React.FC types alone wasn't enough  -  the underlying @react-email render function needed the matching change too. Typing improvements shipped via PR #401; maintainers asked anyone still seeing this on the latest Resend SDK + React versions to reopen. Community workaround: drop the React.FC annotation and declare the email as a plain JSX function.

Evidence

Asked in gh:resend/resend-node#124 (https://github.com/resend/resend-node/issues/124): React.FC returns ReactNode since 18.2. The issue report: Issue resend/resend-node#124 (closed, 5 comments): Upgraded to the latest version of @types/react and a FunctionalComponent no longer returns a ReactElement which resend expects, instead a ReactNode is returned

From the @types/react codebase:

Version 18.0.28

interface FunctionComponent[P = {}] {
    (props: P, context?: any): ReactElement[any, any] | null;
    propTypes?: WeakValidationMap[P] | undefined;
    contextTypes?: ValidationMap[any] | undefined;
    defaultProps?: Partial[P] | undefined;
    displayName?: string | undefined;
}

Version 18.2.14

interface FunctionComponent[P = {}] { The verified answer: [jayanratna / vcapretz (maintainers)]: Updating the SDK's React.FC types alone wasn't enough  -  the underlying @react-email render function needed the matching change too. Typing improvements shipped via PR #401; maintainers asked anyone still seeing this on the latest Resend SDK + React versions to reopen. Community workaround: drop the React.FC annotation and declare the email as a plain JSX function.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_hmsAEqRz_eRjyfQA7vvC5g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">React.FC returns ReactNode since 18.2 <span>— Vectle</span></a>