Skip to content

Commit 36103ee

Browse files
one step further
1 parent c35a00d commit 36103ee

File tree

9 files changed

+53
-54
lines changed

9 files changed

+53
-54
lines changed

docs/data/material/getting-started/templates/shared-theme/AppTheme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function AppTheme({ children, disableCustomTheme, themeComponents }) {
3434
});
3535
}, [disableCustomTheme, themeComponents]);
3636
if (disableCustomTheme) {
37-
return <React.Fragment>{children}</React.Fragment>;
37+
return children;
3838
}
3939
return (
4040
<ThemeProvider theme={theme} disableTransitionOnChange>

docs/data/material/getting-started/templates/shared-theme/AppTheme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function AppTheme({
4646
});
4747
}, [disableCustomTheme, themeComponents]);
4848
if (disableCustomTheme) {
49-
return <React.Fragment>{children}</React.Fragment>;
49+
return children;
5050
}
5151
return (
5252
<ThemeProvider theme={theme} disableTransitionOnChange>

packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -635,43 +635,49 @@ export default async function generateComponentApi(
635635
} catch (error) {
636636
// fallback to default logic if there is no `create*` definition.
637637
if ((error as Error).message === 'No suitable component definition found.') {
638-
reactApi = docgenParse(src, (ast) => {
639-
let node;
640-
// TODO migrate to react-docgen v6, using Babel AST now
641-
astTypes.visit(ast, {
642-
visitFunctionDeclaration: (path) => {
643-
if (path.node.params[0].name === 'props') {
644-
node = path;
645-
}
646-
return false;
647-
},
648-
visitVariableDeclaration: (path) => {
649-
const definitions: any[] = [];
650-
if (path.node.declarations) {
651-
path
652-
.get('declarations')
653-
.each((declarator: any) => definitions.push(declarator.get('init')));
654-
}
655-
definitions.forEach((definition) => {
656-
// definition.value.expression is defined when the source is in TypeScript.
657-
const expression = definition.value?.expression
658-
? definition.get('expression')
659-
: definition;
660-
if (expression.value?.callee) {
661-
const definitionName = expression.value.callee.name;
662-
if (definitionName === `create${componentInfo.name}`) {
663-
node = expression;
664-
}
638+
reactApi = docgenParse(
639+
src,
640+
(ast) => {
641+
let node;
642+
// TODO migrate to react-docgen v6, using Babel AST now
643+
astTypes.visit(ast, {
644+
visitFunctionDeclaration: (functionPath) => {
645+
// @ts-ignore
646+
if (functionPath.node.params[0].name === 'props') {
647+
node = functionPath;
665648
}
666-
});
667-
return false;
668-
},
669-
});
649+
return false;
650+
},
651+
visitVariableDeclaration: (variablePath) => {
652+
const definitions: any[] = [];
653+
if (variablePath.node.declarations) {
654+
variablePath
655+
.get('declarations')
656+
.each((declarator: any) => definitions.push(declarator.get('init')));
657+
}
658+
definitions.forEach((definition) => {
659+
// definition.value.expression is defined when the source is in TypeScript.
660+
const expression = definition.value?.expression
661+
? definition.get('expression')
662+
: definition;
663+
if (expression.value?.callee) {
664+
const definitionName = expression.value.callee.name;
665+
if (definitionName === `create${componentInfo.name}`) {
666+
node = expression;
667+
}
668+
}
669+
});
670+
return false;
671+
},
672+
});
670673

671-
return node;
672-
}, defaultHandlers, {
673-
filename,
674-
});
674+
return node;
675+
},
676+
defaultHandlers,
677+
{
678+
filename,
679+
},
680+
);
675681
} else {
676682
throw error;
677683
}

packages/mui-base/src/ClickAwayListener/ClickAwayListener.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function ClickAwayListener(props: ClickAwayListenerProps): React.JSX.Element {
209209
return undefined;
210210
}, [handleClickAway, mouseEvent]);
211211

212-
return <React.Fragment>{React.cloneElement(children, childrenProps)}</React.Fragment>;
212+
return React.cloneElement(children, childrenProps);
213213
}
214214

215215
ClickAwayListener.propTypes /* remove-proptypes */ = {

packages/mui-base/src/NoSsr/NoSsr.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function NoSsr(props: NoSsrProps): React.JSX.Element {
3838
}
3939
}, [defer]);
4040

41-
// We need the Fragment here to force react-docgen to recognise NoSsr as a component.
42-
return <React.Fragment>{mountedState ? children : fallback}</React.Fragment>;
41+
// TODO casting won't be needed at one point https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65135
42+
return (mountedState ? children : fallback) as React.JSX.Element;
4343
}
4444

4545
NoSsr.propTypes /* remove-proptypes */ = {

packages/mui-base/src/Portal/Portal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,10 @@ const Portal = React.forwardRef(function Portal(
6464
};
6565
return React.cloneElement(children, newProps);
6666
}
67-
return <React.Fragment>{children}</React.Fragment>;
67+
return children;
6868
}
6969

70-
return (
71-
<React.Fragment>
72-
{mountNode ? ReactDOM.createPortal(children, mountNode) : mountNode}
73-
</React.Fragment>
74-
);
70+
return mountNode ? ReactDOM.createPortal(children, mountNode) : mountNode;
7571
}) as React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<Element>>;
7672

7773
Portal.propTypes /* remove-proptypes */ = {

packages/mui-material/src/Hidden/HiddenJs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function HiddenJs(props) {
5050
return null;
5151
}
5252

53-
return <React.Fragment>{children}</React.Fragment>;
53+
return children;
5454
}
5555

5656
HiddenJs.propTypes = {

packages/mui-material/src/NoSsr/NoSsr.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function NoSsr(props: NoSsrProps): React.JSX.Element {
3838
}
3939
}, [defer]);
4040

41-
return <React.Fragment>{mountedState ? children : fallback}</React.Fragment>;
41+
// TODO casting won't be needed at one point https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65135
42+
return (mountedState ? children : fallback) as React.JSX.Element;
4243
}
4344

4445
NoSsr.propTypes /* remove-proptypes */ = {

packages/mui-material/src/Portal/Portal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,10 @@ const Portal = React.forwardRef(function Portal(
6464
};
6565
return React.cloneElement(children, newProps);
6666
}
67-
return <React.Fragment>{children}</React.Fragment>;
67+
return children;
6868
}
6969

70-
return (
71-
<React.Fragment>
72-
{mountNode ? ReactDOM.createPortal(children, mountNode) : mountNode}
73-
</React.Fragment>
74-
);
70+
return mountNode ? ReactDOM.createPortal(children, mountNode) : mountNode;
7571
}) as React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<Element>>;
7672

7773
Portal.propTypes /* remove-proptypes */ = {

0 commit comments

Comments
 (0)