From f0017ce71efa5147e327bacd3602040759db70e8 Mon Sep 17 00:00:00 2001 From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Date: Mon, 8 Nov 2021 15:32:20 +0100 Subject: [PATCH] [Fleet] Fixing unnecessary network requests on showing Fleet Server on prem instructions (#117647) * removed fn dependency * fixing useDefaultOutput * fixed tslint --- .../fleet/public/hooks/use_request/outputs.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/fleet/public/hooks/use_request/outputs.ts b/x-pack/plugins/fleet/public/hooks/use_request/outputs.ts index 2d623da505c65..214fa5f5ed142 100644 --- a/x-pack/plugins/fleet/public/hooks/use_request/outputs.ts +++ b/x-pack/plugins/fleet/public/hooks/use_request/outputs.ts @@ -5,8 +5,6 @@ * 2.0. */ -import { useMemo, useCallback } from 'react'; - import { outputRoutesService } from '../../services'; import type { PutOutputRequest, GetOutputsResponse } from '../../types'; @@ -21,17 +19,9 @@ export function useGetOutputs() { export function useDefaultOutput() { const outputsRequest = useGetOutputs(); - const output = useMemo(() => { - return outputsRequest.data?.items.find((o) => o.is_default); - }, [outputsRequest.data]); - - const refresh = useCallback(() => { - return outputsRequest.resendRequest(); - }, [outputsRequest]); + const output = outputsRequest.data?.items.find((o) => o.is_default); - return useMemo(() => { - return { output, refresh }; - }, [output, refresh]); + return { output, refresh: outputsRequest.resendRequest }; } export function sendPutOutput(outputId: string, body: PutOutputRequest['body']) {