Skip to content

Commit 596ccf3

Browse files
committed
support user custom loading component
fix: #123
1 parent 2963b93 commit 596ccf3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/theme-doc/src/ThemeConfig.doc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ export interface ThemeConfig {
4343
| FooterConfig
4444
| ((ctx: ThemeContextValue) => FooterConfig | null | undefined)
4545
/**
46-
* View to be rendered when app in 404 state
46+
* Component to be rendered when app in 404 state
4747
* (url not matching any page)
4848
*/
4949
Component404?: React.ComponentType<React.PropsWithChildren<unknown>>
50+
/**
51+
* Component to be rendered when app is loading js bundle
52+
*/
53+
ComponentLoading?: React.ComponentType<React.PropsWithChildren<unknown>>
5054
/**
5155
* Wrap the App with custom Component.
5256
* You can use `useThemeCtx()` in it to get context info

packages/theme-doc/src/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function createTheme(
2929

3030
const location = useLocation()
3131
useIsomorphicLayoutEffect(() => {
32-
// scroll to anchor after page component loaded
32+
// scroll to anchor link after page component loaded
3333
if (loadState.type === 'loaded') {
3434
if (location.hash) {
3535
AnchorLink.scrollToAnchor(decodeURIComponent(location.hash.slice(1)))
@@ -40,7 +40,10 @@ export function createTheme(
4040
}, [loadState, location.hash])
4141

4242
if (loadState.type === 'loading') {
43-
return <AppLayout></AppLayout>
43+
const ComponentLoading = themeConfig.ComponentLoading
44+
return (
45+
<AppLayout>{ComponentLoading ? <ComponentLoading /> : null}</AppLayout>
46+
)
4447
}
4548

4649
if (loadState.type === 'load-error') {

0 commit comments

Comments
 (0)