Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Observability Homepage] Fix console error because of side effect #75258

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <></>;
}