From bce1c6cf40ba953b558b3c55993ffe9a2198ec9d Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 7 Jul 2021 07:43:12 -0400 Subject: [PATCH] [Fleet][Logs UI] Ensure the component reacts to query changes (#103876) (#104598) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ensure the component reacts to query changes * Remove unused import Co-authored-by: Alejandro Fernández Gómez --- .../infra/public/containers/logs/log_stream/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/infra/public/containers/logs/log_stream/index.ts b/x-pack/plugins/infra/public/containers/logs/log_stream/index.ts index 4cdeb678c432b..9d85316d978eb 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_stream/index.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_stream/index.ts @@ -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'; @@ -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(() => { @@ -89,7 +88,7 @@ export function useLogStream({ sourceId, startTimestamp, endTimestamp, - query: cachedQuery.current, + query: cachedQuery, columnOverrides: columns, }), [columns, endTimestamp, cachedQuery, sourceId, startTimestamp]