diff --git a/x-pack/plugins/index_management/public/app.js b/x-pack/plugins/index_management/public/app.js
index c0b01f63919c..de978674206f 100644
--- a/x-pack/plugins/index_management/public/app.js
+++ b/x-pack/plugins/index_management/public/app.js
@@ -5,13 +5,14 @@
*/
import React from 'react';
-import { Switch, Route } from 'react-router-dom';
+import { Switch, Route, Redirect } from 'react-router-dom';
import { BASE_PATH } from '../common/constants';
import { IndexList } from './sections/index_list';
export const App = () => (
+
diff --git a/x-pack/plugins/index_management/public/register_routes.js b/x-pack/plugins/index_management/public/register_routes.js
index 3d907f8a9968..42074935298a 100644
--- a/x-pack/plugins/index_management/public/register_routes.js
+++ b/x-pack/plugins/index_management/public/register_routes.js
@@ -5,7 +5,7 @@
*/
import React from 'react';
-import { render } from 'react-dom';
+import { render, unmountComponentAtNode } from 'react-dom';
import { Provider } from 'react-redux';
import { HashRouter } from 'react-router-dom';
import { I18nProvider } from '@kbn/i18n/react';
@@ -21,6 +21,7 @@ import template from './main.html';
import { manageAngularLifecycle } from './lib/manage_angular_lifecycle';
import { indexManagementStore } from './store';
+let elem;
const renderReact = async (elem) => {
render(
@@ -39,6 +40,9 @@ routes.when(`${BASE_PATH}:view?/:action?/:id?`, {
controllerAs: 'indexManagement',
controller: class IndexManagementController {
constructor($scope, $route, $http, kbnUrl, $rootScope) {
+ // clean up previously rendered React app if one exists
+ // this happens because of React Router redirects
+ elem && unmountComponentAtNode(elem);
// NOTE: We depend upon Angular's $http service because it's decorated with interceptors,
// e.g. to check license status per request.
setHttpClient($http);
@@ -49,7 +53,7 @@ routes.when(`${BASE_PATH}:view?/:action?/:id?`, {
}
});
$scope.$$postDigest(() => {
- const elem = document.getElementById('indexManagementReactRoot');
+ elem = document.getElementById('indexManagementReactRoot');
renderReact(elem);
manageAngularLifecycle($scope, $route, elem);
});