Skip to content

Commit 2159042

Browse files
author
marco
committed
latest
1 parent 8bb7b7d commit 2159042

File tree

1 file changed

+19
-12
lines changed
  • components/webui/client/src/pages/SearchPage/SearchState/Presto/useTimestampKeyInit

1 file changed

+19
-12
lines changed

components/webui/client/src/pages/SearchPage/SearchState/Presto/useTimestampKeyInit/index.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,26 @@ const useTimestampKeyInit = () => {
3232
enabled: null !== dataset,
3333
});
3434

35-
if (isSuccess) {
36-
if ("undefined" !== typeof timestampKeys[0] && null === timestampKey) {
37-
updateTimestampKey(timestampKeys[0]);
35+
// Reset timestamp key when dataset changes.
36+
useEffect(() => {
37+
updateTimestampKey(null);
38+
}, [
39+
dataset,
40+
updateTimestampKey,
41+
]);
42+
43+
useEffect(() => {
44+
if (isSuccess) {
45+
if ("undefined" !== typeof timestampKeys[0] && null === timestampKey) {
46+
updateTimestampKey(timestampKeys[0]);
47+
}
3848
}
39-
}
49+
}, [
50+
isSuccess,
51+
timestampKeys,
52+
timestampKey,
53+
updateTimestampKey,
54+
]);
4055

4156
// Show error message if fetch fails
4257
useEffect(() => {
@@ -68,14 +83,6 @@ const useTimestampKeyInit = () => {
6883
updateTimestampKey,
6984
]);
7085

71-
// Reset timestamp key when dataset changes.
72-
useEffect(() => {
73-
updateTimestampKey(null);
74-
}, [
75-
dataset,
76-
updateTimestampKey,
77-
]);
78-
7986
return {contextHolder};
8087
};
8188

0 commit comments

Comments
 (0)