Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): swizzle wrap should use ReactNode instead of JSX.Element #10747

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export default function FirstLevelComponentWrapper(props) {
`;

exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import ComponentInFolder from '@theme-original/ComponentInFolder';
import type ComponentInFolderType from '@theme/ComponentInFolder';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof ComponentInFolderType>;

export default function ComponentInFolderWrapper(props: Props): JSX.Element {
export default function ComponentInFolderWrapper(props: Props): ReactNode {
return (
<>
<ComponentInFolder {...props} />
Expand All @@ -61,14 +61,14 @@ export default function ComponentInFolderWrapper(props: Props): JSX.Element {
`;

exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof ComponentInSubFolderType>;

export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
export default function ComponentInSubFolderWrapper(props: Props): ReactNode {
return (
<>
<ComponentInSubFolder {...props} />
Expand All @@ -79,14 +79,14 @@ export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
`;

exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof FirstLevelComponentType>;

export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
export default function FirstLevelComponentWrapper(props: Props): ReactNode {
return (
<>
<FirstLevelComponent {...props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ exports[`swizzle wrap ComponentInFolder JS: theme dir tree 1`] = `
`;

exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import ComponentInFolder from '@theme-original/ComponentInFolder';
import type ComponentInFolderType from '@theme/ComponentInFolder';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof ComponentInFolderType>;

export default function ComponentInFolderWrapper(props: Props): JSX.Element {
export default function ComponentInFolderWrapper(props: Props): ReactNode {
return (
<>
<ComponentInFolder {...props} />
Expand Down Expand Up @@ -328,14 +328,14 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder JS: theme dir tree
`;

exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFolder/ComponentInSubFolder/index.tsx 1`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof ComponentInSubFolderType>;

export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
export default function ComponentInSubFolderWrapper(props: Props): ReactNode {
return (
<>
<ComponentInSubFolder {...props} />
Expand Down Expand Up @@ -373,14 +373,14 @@ exports[`swizzle wrap ComponentInFolder/Sibling JS: theme dir tree 1`] = `
`;

exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.tsx 1`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import Sibling from '@theme-original/ComponentInFolder/Sibling';
import type SiblingType from '@theme/ComponentInFolder/Sibling';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof SiblingType>;

export default function SiblingWrapper(props: Props): JSX.Element {
export default function SiblingWrapper(props: Props): ReactNode {
return (
<>
<Sibling {...props} />
Expand Down Expand Up @@ -416,14 +416,14 @@ exports[`swizzle wrap FirstLevelComponent JS: theme dir tree 1`] = `
`;

exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
"import React from 'react';
"import React, {type ReactNode} from 'react';
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof FirstLevelComponentType>;

export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
export default function FirstLevelComponentWrapper(props: Props): ReactNode {
return (
<>
<FirstLevelComponent {...props} />
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/src/commands/swizzle/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ export async function wrap({
const toPath = path.resolve(siteDir, THEME_PATH, wrapperFileName);

const content = typescript
? `import React from 'react';
? `import React, {type ReactNode} from 'react';
import ${componentName} from '@theme-${importType}/${themeComponentName}';
import type ${componentName}Type from '@theme/${themeComponentName}';
import type {WrapperProps} from '@docusaurus/types';

type Props = WrapperProps<typeof ${componentName}Type>;

export default function ${wrapperComponentName}(props: Props): JSX.Element {
export default function ${wrapperComponentName}(props: Props): ReactNode {
return (
<>
<${componentName} {...props} />
Expand Down
Loading