Skip to content

Commit a03961f

Browse files
committed
Import react-markdown async
1 parent 5c6caf6 commit a03961f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/core/public/overlays/banners/user_banner_service.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919

2020
import React, { Fragment } from 'react';
2121
import ReactDOM from 'react-dom';
22-
import ReactMarkdown from 'react-markdown';
2322
import { filter } from 'rxjs/operators';
2423
import { Subscription } from 'rxjs';
2524

2625
import { FormattedMessage } from '@kbn/i18n/react';
27-
import { EuiCallOut, EuiButton } from '@elastic/eui';
26+
import { EuiCallOut, EuiButton, EuiLoadingSpinner } from '@elastic/eui';
2827

2928
import { I18nStart } from '../../i18n';
3029
import { IUiSettingsClient } from '../../ui_settings';
@@ -36,6 +35,8 @@ interface StartDeps {
3635
uiSettings: IUiSettingsClient;
3736
}
3837

38+
const ReactMarkdownLazy = React.lazy(() => import('react-markdown'));
39+
3940
/**
4041
* Sets up the custom banner that can be specified in advanced settings.
4142
* @internal
@@ -75,7 +76,15 @@ export class UserBannerService {
7576
}
7677
iconType="help"
7778
>
78-
<ReactMarkdown renderers={{ root: Fragment }}>{content.trim()}</ReactMarkdown>
79+
<React.Suspense
80+
fallback={
81+
<div>
82+
<EuiLoadingSpinner />
83+
</div>
84+
}
85+
>
86+
<ReactMarkdownLazy renderers={{ root: Fragment }} source={content.trim()} />
87+
</React.Suspense>
7988

8089
<EuiButton type="primary" size="s" onClick={() => banners.remove(id!)}>
8190
<FormattedMessage

0 commit comments

Comments
 (0)