8000 refactor(core): swizzle wrap should use ReactNode instead of JSX.Elem… · facebook/docusaurus@4966dce · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 4966dce

Browse files
authored
refactor(core): swizzle wrap should use ReactNode instead of JSX.Element (#10747)
1 parent f9825af commit 4966dce

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/actions.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export default function FirstLevelComponentWrapper(props) {
4343
`;
4444

4545
exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
46-
"import React from 'react';
46+
"import React, {type ReactNode} from 'react';
4747
import ComponentInFolder from '@theme-original/ComponentInFolder';
4848
import type ComponentInFolderType from '@theme/ComponentInFolder';
4949
import type {WrapperProps} from '@docusaurus/types';
5050
5151
type Props = WrapperProps<typeof ComponentInFolderType>;
5252
53-
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
53+
export default function ComponentInFolderWrapper(props: Props): ReactNode {
5454
return (
5555
<>
5656
<ComponentInFolder {...props} />
@@ -61,14 +61,14 @@ export default function ComponentInFolderWrapper(props: Props): JSX.Element {
6161
`;
6262
6363
exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
64-
"import React from 'react';
64+
"import React, {type ReactNode} from 'react';
6565
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
6666
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
6767
import type {WrapperProps} from '@docusaurus/types';
6868
6969
type Props = WrapperProps<typeof ComponentInSubFolderType>;
7070
71-
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
71+
export default function ComponentInSubFolderWrapper(props: Props): ReactNode {
7272
return (
7373
<>
7474
<ComponentInSubFolder {...props} />
< 10000 div class="d-flex flex-row">
@@ -79,14 +79,14 @@ export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
7979
`;
8080
8181
exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
82-
"import React from 'react';
82+
"import React, {type ReactNode} from 'react';
8383
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
8484
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
8585
import type {WrapperProps} from '@docusaurus/types';
8686
8787
type Props = WrapperProps<typeof FirstLevelComponentType>;
8888
89-
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
89+
export default function FirstLevelComponentWrapper(props: Props): ReactNode {
9090
return (
9191
<>
9292
<FirstLevelComponent {...props} />

packages/docusaurus/src/commands/swizzle/__tests__/__snapshots__/index.test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ exports[`swizzle wrap ComponentInFolder JS: theme dir tree 1`] = `
283283
`;
284284

285285
exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
286-
"import React from 'react';
286+
"import React, {type ReactNode} from 'react';
287287
import ComponentInFolder from '@theme-original/ComponentInFolder';
288288
import type ComponentInFolderType from '@theme/ComponentInFolder';
289289
import type {WrapperProps} from '@docusaurus/types';
290290
291291
type Props = WrapperProps<typeof ComponentInFolderType>;
292292
293-
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
293+
export default function ComponentInFolderWrapper(props: Props): ReactNode {
294294
return (
295295
<>
296296
<ComponentInFolder {...props} />
@@ -328,14 +328,14 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder JS: theme dir tree
328328
`;
329329
330330
exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFolder/ComponentInSubFolder/index.tsx 1`] = `
331-
"import React from 'react';
331+
"import React, {type ReactNode} from 'react';
332332
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
333333
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
334334
import type {WrapperProps} from '@docusaurus/types';
335335
336336
type Props = WrapperProps<typeof ComponentInSubFolderType>;
337337
338-
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
338+
export default function ComponentInSubFolderWrapper(props: Props): ReactNode {
339339
return (
340340
<>
341341
<ComponentInSubFolder {...props} />
@@ -373,14 +373,14 @@ exports[`swizzle wrap ComponentInFolder/Sibling JS: theme dir tree 1`] = `
373373
`;
374374
375375
exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.tsx 1`] = `
376-
"import React from 'react';
376+
"import React, {type ReactNode} from 'react';
377377
import Sibling from '@theme-original/ComponentInFolder/Sibling';
378378
import type SiblingType from '@theme/ComponentInFolder/Sibling';
379379
import type {WrapperProps} from '@docusaurus/types';
380380
381381
type Props = WrapperProps<typeof SiblingType>;
382382
383-
export default function SiblingWrapper(props: Props): JSX.Element {
383+
export default function SiblingWrapper(props: Props): ReactNode {
384384
return (
385385
<>
386386
<Sibling {...props} />
@@ -416,14 +416,14 @@ exports[`swizzle wrap FirstLevelComponent JS: theme dir tree 1`] = `
416416
`;
417417
418418
exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
419-
"import React from 'react';
419+
"import React, {type ReactNode} from 'react';
420420
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
421421
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
422422
import type {WrapperProps} from '@docusaurus/types';
423423
424424
type Props = WrapperProps<typeof FirstLevelComponentType>;
425425
426-
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
426+
export default function FirstLevelComponentWrapper(props: Props): ReactNode {
427427
return (
428428
<>
429429
<FirstLevelComponent {...props} />

packages/docusaurus/src/commands/swizzle/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ export async function wrap({
128128
const toPath = path.resolve(siteDir, THEME_PATH, wrapperFileName);
129129

130130
const content = typescript
131-
? `import React from 'react';
131+
? `import React, {type ReactNode} from 'react';
132132
import ${componentName} from '@theme-${importType}/${themeComponentName}';
133133
import type ${componentName}Type from '@theme/${themeComponentName}';
134134
import type {WrapperProps} from '@docusaurus/types';
135135
136136
type Props = WrapperProps<typeof ${componentName}Type>;
137137
138-
export default function ${wrapperComponentName}(props: Props): JSX.Element {
138+
export default function ${wrapperComponentName}(props: Props): ReactNode {
139139
return (
140140
<>
141141
<${componentName} {...props} />

0 commit comments

Comments
 (0)
0