Skip to content

Commit

Permalink
load VizOptions component lazily
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Apr 29, 2020
1 parent 8bb67f2 commit 3881b10
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,6 @@ function TableOptions({
</EuiPanel>
);
}

export { TableOptions };
// default export required for React.Lazy
// eslint-disable-next-line import/no-default-export
export { TableOptions as default };
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React, { lazy, Suspense } from 'react';
import { EuiLoadingSpinner } from '@elastic/eui';
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { TableVisParams } from '../types';

const TableOptionsComponent = lazy(() => import('./table_vis_options'));

export const TableOptions = (props: VisOptionsProps<TableVisParams>) => (
<Suspense fallback={<EuiLoadingSpinner />}>
<TableOptionsComponent {...props} />
</Suspense>
);
2 changes: 1 addition & 1 deletion src/plugins/vis_type_table/public/table_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Vis } from '../../visualizations/public';
import { tableVisResponseHandler } from './table_vis_response_handler';
// @ts-ignore
import tableVisTemplate from './table_vis.html';
import { TableOptions } from './components/table_vis_options';
import { TableOptions } from './components/table_vis_options_lazy';
import { getTableVisualizationControllerClass } from './vis_controller';

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

0 comments on commit 3881b10

Please sign in to comment.