File tree Expand file tree Collapse file tree 1 file changed +19
-12
lines changed
components/webui/client/src/pages/SearchPage/SearchState/Presto/useTimestampKeyInit Expand file tree Collapse file tree 1 file changed +19
-12
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments