diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index 6269c11fca896..8c3e0c066f411 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -23,45 +23,16 @@ type MlDependencies = MlSetupDependencies & MlStartDependencies; interface AppProps { coreStart: CoreStart; deps: MlDependencies; - appMountParams: AppMountParameters; } const localStorage = new Storage(window.localStorage); -const App: FC = ({ coreStart, deps, appMountParams }) => { - setDependencyCache({ - indexPatterns: deps.data.indexPatterns, - timefilter: deps.data.query.timefilter, - fieldFormats: deps.data.fieldFormats, - autocomplete: deps.data.autocomplete, - config: coreStart.uiSettings!, - chrome: coreStart.chrome!, - docLinks: coreStart.docLinks!, - toastNotifications: coreStart.notifications.toasts, - overlays: coreStart.overlays, - recentlyAccessed: coreStart.chrome!.recentlyAccessed, - basePath: coreStart.http.basePath, - savedObjectsClient: coreStart.savedObjects.client, - application: coreStart.application, - http: coreStart.http, - security: deps.security, - urlGenerators: deps.share.urlGenerators, - }); - - const mlLicense = setLicenseCache(deps.licensing); - - appMountParams.onAppLeave(actions => { - mlLicense.unsubscribe(); - clearCache(); - return actions.default(); - }); - +const App: FC = ({ coreStart, deps }) => { const pageDeps = { indexPatterns: deps.data.indexPatterns, config: coreStart.uiSettings!, setBreadcrumbs: coreStart.chrome!.setBreadcrumbs, }; - const services = { appName: 'ML', data: deps.data, @@ -85,10 +56,34 @@ export const renderApp = ( deps: MlDependencies, appMountParams: AppMountParameters ) => { - ReactDOM.render( - , - appMountParams.element - ); + setDependencyCache({ + indexPatterns: deps.data.indexPatterns, + timefilter: deps.data.query.timefilter, + fieldFormats: deps.data.fieldFormats, + autocomplete: deps.data.autocomplete, + config: coreStart.uiSettings!, + chrome: coreStart.chrome!, + docLinks: coreStart.docLinks!, + toastNotifications: coreStart.notifications.toasts, + overlays: coreStart.overlays, + recentlyAccessed: coreStart.chrome!.recentlyAccessed, + basePath: coreStart.http.basePath, + savedObjectsClient: coreStart.savedObjects.client, + application: coreStart.application, + http: coreStart.http, + security: deps.security, + urlGenerators: deps.share.urlGenerators, + }); - return () => ReactDOM.unmountComponentAtNode(appMountParams.element); + const mlLicense = setLicenseCache(deps.licensing); + + appMountParams.onAppLeave(actions => actions.default()); + + ReactDOM.render(, appMountParams.element); + + return () => { + mlLicense.unsubscribe(); + clearCache(); + ReactDOM.unmountComponentAtNode(appMountParams.element); + }; };