docs: add fallback for previewer (#44327)

* docs: add fallback for previewer

* chore: code clean
This commit is contained in:
MadCcc 2023-08-21 23:28:14 +08:00 committed by GitHub
parent b26e3a77f9
commit da699b11be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,36 @@
import React, { Suspense } from 'react';
import type { IPreviewerProps } from 'dumi';
import { Skeleton } from 'antd';
import { createStyles } from 'antd-style';
const Previewer = React.lazy(() => import('./Previewer'));
export default (props: IPreviewerProps) => (
<Suspense fallback={null}>
<Previewer {...props} />
</Suspense>
);
const useStyle = createStyles(({ css }) => ({
skeletonWrapper: css`
width: 100% !important;
height: 500px;
margin-bottom: 16px;
`,
}));
export default (props: IPreviewerProps) => {
const { styles } = useStyle();
return (
<Suspense
fallback={
<Skeleton.Node
active
className={styles.skeletonWrapper}
style={{
width: '100%',
height: '100%',
}}
>
{' '}
</Skeleton.Node>
}
>
<Previewer {...props} />
</Suspense>
);
};