From 19107ef0a1d2687124d65d6ba53ffcfbe4c09708 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Mon, 18 Oct 2021 18:29:27 +0100 Subject: [PATCH] Fix test errors (#115183) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/es_ui_shared/public/request/use_request.ts | 9 +++++++-- .../deprecation_types/reindex/flyout/step_progress.tsx | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/es_ui_shared/public/request/use_request.ts b/src/plugins/es_ui_shared/public/request/use_request.ts index 33085bdbf4478d..1241d6222a38fb 100644 --- a/src/plugins/es_ui_shared/public/request/use_request.ts +++ b/src/plugins/es_ui_shared/public/request/use_request.ts @@ -103,8 +103,13 @@ export const useRequest = ( : serializedResponseData; setData(responseData); } - // Setting isLoading to false also acts as a signal for scheduling the next poll request. - setIsLoading(false); + // There can be situations in which a component that consumes this hook gets unmounted when + // the request returns an error. So before changing the isLoading state, check if the component + // is still mounted. + if (isMounted.current === true) { + // Setting isLoading to false also acts as a signal for scheduling the next poll request. + setIsLoading(false); + } }, [requestBody, httpClient, deserializer, clearPollInterval] ); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/step_progress.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/step_progress.tsx index 2de21ad86f839b..01b4fe4eb84fca 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/step_progress.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/reindex/flyout/step_progress.tsx @@ -63,7 +63,7 @@ const Step: React.FunctionComponent = ({
-

{title}

+
{title}
{children &&
{children}
}