Skip to content

Commit

Permalink
[Fleet] Fixing unnecessary network requests on showing Fleet Server o…
Browse files Browse the repository at this point in the history
…n prem instructions (elastic#117647)

* removed fn dependency

* fixing useDefaultOutput

* fixed tslint
  • Loading branch information
juliaElastic authored and kibanamachine committed Nov 8, 2021
1 parent 8e7c842 commit ca4198c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions x-pack/plugins/fleet/public/hooks/use_request/outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2.0.
*/

import { useMemo, useCallback } from 'react';

import { outputRoutesService } from '../../services';
import type { PutOutputRequest, GetOutputsResponse } from '../../types';

Expand All @@ -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']) {
Expand Down

0 comments on commit ca4198c

Please sign in to comment.