Skip to content

Commit 2c02364

Browse files
committed
[ML] Use useEffect for legacy redirect.
1 parent 686e6d8 commit 2c02364

File tree

1 file changed

+7
-6
lines changed
  • x-pack/plugins/ml/public/application/routing

1 file changed

+7
-6
lines changed

x-pack/plugins/ml/public/application/routing/router.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React, { FC } from 'react';
7+
import React, { useEffect, FC } from 'react';
88
import { useHistory, useLocation, Router, Route, RouteProps } from 'react-router-dom';
99
import { Location } from 'history';
1010

@@ -56,11 +56,12 @@ const LegacyHashUrlRedirect: FC = ({ children }) => {
5656
const history = useHistory();
5757
const location = useLocation();
5858

59-
if (location.hash.startsWith('#/')) {
60-
const newHash = location.hash.replace('#', '');
61-
history.push(newHash);
62-
return null;
63-
}
59+
useEffect(() => {
60+
if (location.hash.startsWith('#/')) {
61+
const newHash = location.hash.replace('#', '');
62+
history.push(newHash);
63+
}
64+
}, [location.hash]);
6465

6566
return <>{children}</>;
6667
};

0 commit comments

Comments
 (0)