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 ca50a351e0a1..2936664a1285 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 { i18n } from '@kbn/i18n';
@@ -23,6 +23,7 @@ import template from './main.html';
import { manageAngularLifecycle } from './lib/manage_angular_lifecycle';
import { indexManagementStore } from './store';
+let elem;
const renderReact = async (elem) => {
render(
@@ -49,6 +50,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);
@@ -59,7 +63,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);
});