Skip to content

Commit 32ba541

Browse files
committed
feat: use React.FC
1 parent 12e6b98 commit 32ba541

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

electron/renderer/components/chrome/chrome.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22

33
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
44
import createCache from '@emotion/cache';
5-
import { FunctionComponent } from 'react';
5+
import { ReactNode } from 'react';
66
import { useTheme } from '../theme/theme';
77

8+
interface ChromeProviderProps {
9+
children?: ReactNode;
10+
}
11+
812
/**
913
* Renders the UI that surrounds the page content.
1014
* Must be nested within the `ThemeProvider`.
1115
*/
12-
export const ChromeProvider: FunctionComponent<any> = ({ children }) => {
16+
const ChromeProvider: React.FC<ChromeProviderProps> = (
17+
props: ChromeProviderProps
18+
) => {
19+
const { children } = props;
20+
1321
const { colorMode } = useTheme();
1422

1523
/**
@@ -45,3 +53,5 @@ function getNodeBySelector(selector: string): Node | undefined {
4553
return document.querySelector(selector) ?? undefined;
4654
}
4755
}
56+
57+
export { ChromeProvider };

electron/renderer/components/logger/logger.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FunctionComponent, createContext, useContext, useEffect } from 'react';
1+
import { ReactNode, createContext, useContext, useEffect } from 'react';
22
import { Logger } from '../../../common/logger/logger.types';
33
import {
44
createLogger,
@@ -20,9 +20,16 @@ const LoggerContext = createContext<LoggerContextValue>({
2020
logger,
2121
createLogger,
2222
});
23-
LoggerContext.displayName = 'LoggerContext'; // for dev tools
2423

25-
export const LoggerProvider: FunctionComponent<any> = ({ children }) => {
24+
interface LoggerProviderProps {
25+
children: ReactNode;
26+
}
27+
28+
const LoggerProvider: React.FC<LoggerProviderProps> = (
29+
props: LoggerProviderProps
30+
) => {
31+
const { children } = props;
32+
2633
useEffect(() => {
2734
// Once client-side, start monitoring unhandled exceptions on the window.
2835
startMonitoringUnhandledExceptions();
@@ -38,7 +45,7 @@ export const LoggerProvider: FunctionComponent<any> = ({ children }) => {
3845
);
3946
};
4047

41-
export const useLogger = (scope?: string): LoggerContextValue => {
48+
const useLogger = (scope?: string): LoggerContextValue => {
4249
const context = useContext(LoggerContext);
4350
if (scope) {
4451
return {
@@ -48,3 +55,5 @@ export const useLogger = (scope?: string): LoggerContextValue => {
4855
}
4956
return context;
5057
};
58+
59+
export { LoggerProvider, useLogger };

electron/renderer/components/theme/theme.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// https://github.com/elastic/next-eui-starter/blob/master/src/components/theme.tsx
22

33
import {
4-
FunctionComponent,
4+
ReactNode,
55
createContext,
66
useContext,
77
useEffect,
@@ -23,9 +23,16 @@ interface ThemeContextValue {
2323
}
2424

2525
const ThemeContext = createContext<ThemeContextValue>({});
26-
ThemeContext.displayName = 'ThemeContext'; // for dev tools
2726

28-
export const ThemeProvider: FunctionComponent<any> = ({ children }) => {
27+
interface ThemeProviderProps {
28+
children?: ReactNode;
29+
}
30+
31+
const ThemeProvider: React.FC<ThemeProviderProps> = (
32+
props: ThemeProviderProps
33+
) => {
34+
const { children } = props;
35+
2936
const [colorMode, setColorMode] = useState(getDefaultThemeName());
3037

3138
// On initial mount in the browser, use any theme from local storage.
@@ -45,6 +52,8 @@ export const ThemeProvider: FunctionComponent<any> = ({ children }) => {
4552
);
4653
};
4754

48-
export const useTheme = (): ThemeContextValue => {
55+
const useTheme = (): ThemeContextValue => {
4956
return useContext(ThemeContext);
5057
};
58+
59+
export { ThemeProvider, useTheme };

0 commit comments

Comments
 (0)