Skip to content

Commit fa5bae8

Browse files
committed
Enable UI shell to render all kinds of child elements
1 parent 8449e29 commit fa5bae8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/anvil-ui-ft-shell/src/index.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ interface Props extends TDocumentHeadProps {
1111
enhancedScriptsToLoad: string[]
1212
}
1313

14+
function renderComponent(Component) {
15+
if (typeof Component === 'string') {
16+
return <body dangerouslySetInnerHTML={{ __html: Component }} />
17+
} else if (typeof Component === 'function') {
18+
return (
19+
<body>
20+
<Component />
21+
</body>
22+
)
23+
} else {
24+
return <body>{Component}</body>
25+
}
26+
}
27+
1428
export default function Shell(props: Props) {
1529
const coreScripts = [corePolyfillServiceUrl, ...props.coreScriptsToLoad]
1630
const enhancedScripts = [enhancedPolyfillServiceUrl, ...props.enhancedScriptsToLoad]
@@ -32,7 +46,7 @@ export default function Shell(props: Props) {
3246
/>
3347
<script dangerouslySetInnerHTML={{ __html: getBootstrapJS() }} />
3448
</head>
35-
<body>{props.children}</body>
49+
{renderComponent(props.children)}
3650
</html>
3751
)
3852
}

0 commit comments

Comments
 (0)