mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adapt to more familiar pattern for higher order components
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
19ded006c0
commit
77195c5222
@ -6,25 +6,26 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { Router } from "react-router";
|
||||
import historyInjectable from "../navigation/history.injectable";
|
||||
import React from "react";
|
||||
|
||||
import {
|
||||
reactApplicationWrapperInjectionToken,
|
||||
reactApplicationHigherOrderComponentInjectionToken,
|
||||
} from "@k8slens/react-application-root";
|
||||
|
||||
const routingApplicationRootWrapperInjectable = getInjectable({
|
||||
id: "routing-application-root-wrapper",
|
||||
const routingReactApplicationHocInjectable = getInjectable({
|
||||
id: "routing-react-application-hoc",
|
||||
|
||||
instantiate: (di) => {
|
||||
const history = di.inject(historyInjectable);
|
||||
|
||||
return (Component) => () =>
|
||||
return ({ children }) =>
|
||||
(
|
||||
<Router history={history}>
|
||||
<Component />
|
||||
{children}
|
||||
</Router>
|
||||
);
|
||||
},
|
||||
|
||||
injectionToken: reactApplicationWrapperInjectionToken,
|
||||
injectionToken: reactApplicationHigherOrderComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default routingApplicationRootWrapperInjectable;
|
||||
export default routingReactApplicationHocInjectable;
|
||||
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import React from "react";
|
||||
import {
|
||||
reactApplicationWrapperInjectionToken,
|
||||
} from "@k8slens/react-application-root";
|
||||
import { ThemeProvider } from "@material-ui/core";
|
||||
import { defaultMuiBaseTheme } from "../mui-base-theme";
|
||||
|
||||
const themeProviderApplicationRootWrapperInjectable = getInjectable({
|
||||
id: "theme-provider-application-root-wrapper",
|
||||
|
||||
instantiate: () => (Component) => () =>
|
||||
(
|
||||
<ThemeProvider theme={defaultMuiBaseTheme}>
|
||||
<Component />
|
||||
</ThemeProvider>
|
||||
),
|
||||
|
||||
injectionToken: reactApplicationWrapperInjectionToken,
|
||||
});
|
||||
|
||||
export default themeProviderApplicationRootWrapperInjectable;
|
||||
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import React from "react";
|
||||
import { reactApplicationHigherOrderComponentInjectionToken } from "@k8slens/react-application-root";
|
||||
import { ThemeProvider } from "@material-ui/core";
|
||||
import { defaultMuiBaseTheme } from "../mui-base-theme";
|
||||
|
||||
const themeProviderReactApplicationHocInjectable = getInjectable({
|
||||
id: "theme-provider-react-application-hoc",
|
||||
|
||||
instantiate:
|
||||
() =>
|
||||
({ children }) =>
|
||||
<ThemeProvider theme={defaultMuiBaseTheme}>{children}</ThemeProvider>,
|
||||
|
||||
injectionToken: reactApplicationHigherOrderComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default themeProviderReactApplicationHocInjectable;
|
||||
Loading…
Reference in New Issue
Block a user