-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[file upload] lazy load to reduce page load size
- Loading branch information
Showing
5 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/file_upload/public/get_file_upload_component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { React } from 'react'; | ||
|
||
let lazyLoadPromise: Promise<React.ComponentType<unknown>>; | ||
|
||
export async function getFileUploadComponent(): Promise<React.ComponentType<unknown>> { | ||
if (typeof lazyLoadPromise !== 'undefined') { | ||
return lazyLoadPromise; | ||
} | ||
|
||
lazyLoadPromise = new Promise(async (resolve) => { | ||
// @ts-expect-error | ||
const { JsonUploadAndParse } = await import('./components/json_upload_and_parse'); | ||
resolve(JsonUploadAndParse); | ||
}); | ||
return lazyLoadPromise; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters