Skip to content

Commit

Permalink
[7.x] [Observability Homepage] Fix console error because of side effe…
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Aug 19, 2020
1 parent 93b47ab commit 0ac9a5a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions x-pack/plugins/observability/public/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import React, { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { fetchHasData } from '../../data_handler';
import { useFetcher } from '../../hooks/use_fetcher';
Expand All @@ -15,12 +15,14 @@ export function HomePage() {
const values = Object.values(data);
const hasSomeData = values.length ? values.some((hasData) => hasData) : null;

if (hasSomeData === true) {
history.push({ pathname: '/overview' });
}
if (hasSomeData === false) {
history.push({ pathname: '/landing' });
}
useEffect(() => {
if (hasSomeData === true) {
history.push({ pathname: '/overview' });
}
if (hasSomeData === false) {
history.push({ pathname: '/landing' });
}
}, [hasSomeData, history]);

return <></>;
}

0 comments on commit 0ac9a5a

Please sign in to comment.