Skip to content

Commit cf96bc4

Browse files
load SettingsOptions component lazily (elastic#64638)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent ad5450f commit cf96bc4

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/plugins/vis_type_markdown/public/markdown_vis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
2121

2222
import { MarkdownVisWrapper } from './markdown_vis_controller';
2323
import { MarkdownOptions } from './markdown_options';
24-
import { SettingsOptions } from './settings_options';
24+
import { SettingsOptions } from './settings_options_lazy';
2525
import { DefaultEditorSize } from '../../vis_default_editor/public';
2626

2727
export const markdownVisDefinition = {

src/plugins/vis_type_markdown/public/settings_options.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ function SettingsOptions({ stateParams, setValue }: VisOptionsProps<MarkdownVisP
5252
);
5353
}
5454

55-
export { SettingsOptions };
55+
// default export required for React.Lazy
56+
// eslint-disable-next-line import/no-default-export
57+
export { SettingsOptions as default };
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import React, { lazy, Suspense } from 'react';
21+
import { EuiLoadingSpinner } from '@elastic/eui';
22+
23+
// @ts-ignore
24+
const SettingsOptionsComponent = lazy(() => import('./settings_options'));
25+
26+
export const SettingsOptions = (props: any) => (
27+
<Suspense fallback={<EuiLoadingSpinner />}>
28+
<SettingsOptionsComponent {...props} />
29+
</Suspense>
30+
);

0 commit comments

Comments
 (0)