Skip to content

Commit

Permalink
Import react-markdown async
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Sep 24, 2020
1 parent 5c6caf6 commit a03961f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/public/overlays/banners/user_banner_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@

import React, { Fragment } from 'react';
import ReactDOM from 'react-dom';
import ReactMarkdown from 'react-markdown';
import { filter } from 'rxjs/operators';
import { Subscription } from 'rxjs';

import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCallOut, EuiButton } from '@elastic/eui';
import { EuiCallOut, EuiButton, EuiLoadingSpinner } from '@elastic/eui';

import { I18nStart } from '../../i18n';
import { IUiSettingsClient } from '../../ui_settings';
Expand All @@ -36,6 +35,8 @@ interface StartDeps {
uiSettings: IUiSettingsClient;
}

const ReactMarkdownLazy = React.lazy(() => import('react-markdown'));

/**
* Sets up the custom banner that can be specified in advanced settings.
* @internal
Expand Down Expand Up @@ -75,7 +76,15 @@ export class UserBannerService {
}
iconType="help"
>
<ReactMarkdown renderers={{ root: Fragment }}>{content.trim()}</ReactMarkdown>
<React.Suspense
fallback={
<div>
<EuiLoadingSpinner />
</div>
}
>
<ReactMarkdownLazy renderers={{ root: Fragment }} source={content.trim()} />
</React.Suspense>

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

0 comments on commit a03961f

Please sign in to comment.