Fix double loading of invneotry page when there's a default view (#84843)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Phillip Burch 2020-12-10 13:37:20 -06:00 committed by GitHub
parent 20bad37aa9
commit 92c0a407f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,7 +103,18 @@ export const Layout = () => {
if (currentView != null || !shouldLoadDefault) {
reload();
}
}, [reload, currentView, shouldLoadDefault]);
/**
* INFO: why disable exhaustive-deps
* We need to wait on the currentView not to be null because it is loaded async and could change the view state.
* We don't actually need to watch the value of currentView though, since the view state will be synched up by the
* changing params in the reload method so we should only "watch" the reload method.
*
* TODO: Should refactor this in the future to make it more clear where all the view state is coming
* from and it's precedence [query params, localStorage, defaultView, out of the box view]
*/
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [reload, shouldLoadDefault]);
useEffect(() => {
setShowLoading(true);