-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] [Lens] Avoid unnecessary data fetching on dimension flyout open (…
…#82957) (#83538) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
871df72
commit 583f757
Showing
6 changed files
with
129 additions
and
63 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/helpers.tsx
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,30 @@ | ||
/* | ||
* 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 { useRef } from 'react'; | ||
import useDebounce from 'react-use/lib/useDebounce'; | ||
|
||
export const useDebounceWithOptions = ( | ||
fn: Function, | ||
{ skipFirstRender }: { skipFirstRender: boolean } = { skipFirstRender: false }, | ||
ms?: number | undefined, | ||
deps?: React.DependencyList | undefined | ||
) => { | ||
const isFirstRender = useRef(true); | ||
const newDeps = [...(deps || []), isFirstRender]; | ||
|
||
return useDebounce( | ||
() => { | ||
if (skipFirstRender && isFirstRender.current) { | ||
isFirstRender.current = false; | ||
return; | ||
} | ||
return fn(); | ||
}, | ||
ms, | ||
newDeps | ||
); | ||
}; |
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
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