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 (#117647) (#117866)

* removed fn dependency

* fixing useDefaultOutput

* fixed tslint

Co-authored-by: Julia Bardi <[email protected]>
  • Loading branch information
kibanamachine and juliaElastic authored Nov 8, 2021
1 parent 202dfb5 commit d928d38
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 d928d38

Please sign in to comment.