Skip to content

Commit

Permalink
[Fleet][Logs UI] Ensure the <LogStream /> component reacts to query c…
Browse files Browse the repository at this point in the history
…hanges (#103876) (#104598)

* Ensure the <LogStream /> component reacts to query changes

* Remove unused import

Co-authored-by: Alejandro Fernández Gómez <alejandro.fernandez@elastic.co>
  • Loading branch information
kibanamachine and Alejandro Fernández Gómez authored Jul 7, 2021
1 parent aa2ce8f commit bce1c6c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { isEqual } from 'lodash';
import createContainer from 'constate';
import { useCallback, useEffect, useMemo, useState, useRef } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import usePrevious from 'react-use/lib/usePrevious';
import useSetState from 'react-use/lib/useSetState';
import { esQuery } from '../../../../../../../src/plugins/data/public';
Expand Down Expand Up @@ -66,10 +66,9 @@ export function useLogStream({
const prevStartTimestamp = usePrevious(startTimestamp);
const prevEndTimestamp = usePrevious(endTimestamp);

const cachedQuery = useRef(query);

const [cachedQuery, setCachedQuery] = useState(query);
if (!isEqual(query, cachedQuery)) {
cachedQuery.current = query;
setCachedQuery(query);
}

useEffect(() => {
Expand All @@ -89,7 +88,7 @@ export function useLogStream({
sourceId,
startTimestamp,
endTimestamp,
query: cachedQuery.current,
query: cachedQuery,
columnOverrides: columns,
}),
[columns, endTimestamp, cachedQuery, sourceId, startTimestamp]
Expand Down

0 comments on commit bce1c6c

Please sign in to comment.