Skip to content

Commit

Permalink
[Observability Homepage] Fix console error because of side effect (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 18, 2020
1 parent 2d958e5 commit 7fe263f
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 7fe263f

Please sign in to comment.