Skip to content

Commit d293702

Browse files
load VizOptions component lazily (#64778)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent d4ae987 commit d293702

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/plugins/vis_type_table/public/components/table_vis_options.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@ function TableOptions({
147147
</EuiPanel>
148148
);
149149
}
150-
151-
export { TableOptions };
150+
// default export required for React.Lazy
151+
// eslint-disable-next-line import/no-default-export
152+
export { TableOptions 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+
import React, { lazy, Suspense } from 'react';
20+
import { EuiLoadingSpinner } from '@elastic/eui';
21+
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
22+
import { TableVisParams } from '../types';
23+
24+
const TableOptionsComponent = lazy(() => import('./table_vis_options'));
25+
26+
export const TableOptions = (props: VisOptionsProps<TableVisParams>) => (
27+
<Suspense fallback={<EuiLoadingSpinner />}>
28+
<TableOptionsComponent {...props} />
29+
</Suspense>
30+
);

src/plugins/vis_type_table/public/table_vis_type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { Vis } from '../../visualizations/public';
2424
import { tableVisResponseHandler } from './table_vis_response_handler';
2525
// @ts-ignore
2626
import tableVisTemplate from './table_vis.html';
27-
import { TableOptions } from './components/table_vis_options';
27+
import { TableOptions } from './components/table_vis_options_lazy';
2828
import { getTableVisualizationControllerClass } from './vis_controller';
2929

3030
export function getTableVisTypeDefinition(core: CoreSetup, context: PluginInitializerContext) {

0 commit comments

Comments
 (0)