File tree Expand file tree Collapse file tree
x-pack/plugins/observability/public/pages/home Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * or more contributor license agreements. Licensed under the Elastic License;
44 * you may not use this file except in compliance with the Elastic License.
55 */
6- import React from 'react' ;
6+ import React , { useEffect } from 'react' ;
77import { useHistory } from 'react-router-dom' ;
88import { fetchHasData } from '../../data_handler' ;
99import { useFetcher } from '../../hooks/use_fetcher' ;
@@ -15,12 +15,14 @@ export function HomePage() {
1515 const values = Object . values ( data ) ;
1616 const hasSomeData = values . length ? values . some ( ( hasData ) => hasData ) : null ;
1717
18- if ( hasSomeData === true ) {
19- history . push ( { pathname : '/overview' } ) ;
20- }
21- if ( hasSomeData === false ) {
22- history . push ( { pathname : '/landing' } ) ;
23- }
18+ useEffect ( ( ) => {
19+ if ( hasSomeData === true ) {
20+ history . push ( { pathname : '/overview' } ) ;
21+ }
22+ if ( hasSomeData === false ) {
23+ history . push ( { pathname : '/landing' } ) ;
24+ }
25+ } , [ hasSomeData , history ] ) ;
2426
2527 return < > </ > ;
2628}
You can’t perform that action at this time.
0 commit comments