diff --git a/explorer/package.json b/explorer/package.json index 65ed064da2..916e9b0aeb 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -18,8 +18,8 @@ "d3-scale": "^4.0.0", "date-fns": "^2.24.0", "i18n-iso-countries": "^6.8.0", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-error-boundary": "^3.1.4", "react-google-charts": "^3.0.15", "react-identicons": "^1.2.5", @@ -48,8 +48,8 @@ "@types/geojson": "^7946.0.8", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", - "@types/react": "^17.0.34", - "@types/react-dom": "^17.0.9", + "@types/react": "^18.0.26", + "@types/react-dom": "^18.0.10", "@types/react-simple-maps": "^1.0.6", "@types/react-tooltip": "^4.2.4", "@types/topojson-client": "^3.1.0", diff --git a/explorer/src/App.tsx b/explorer/src/App.tsx index 9ce60f06f9..4e6fcc41e8 100644 --- a/explorer/src/App.tsx +++ b/explorer/src/App.tsx @@ -4,7 +4,7 @@ import { MobileNav } from './components/MobileNav'; import { Routes } from './routes/index'; import { useIsMobile } from './hooks/useIsMobile'; -export const App: React.FC = () => { +export const App: FCWithChildren = () => { const isMobile = useIsMobile(); if (isMobile) { diff --git a/explorer/src/components/ComponentError.tsx b/explorer/src/components/ComponentError.tsx index 34ca4b9d19..00b448fb9e 100644 --- a/explorer/src/components/ComponentError.tsx +++ b/explorer/src/components/ComponentError.tsx @@ -1,7 +1,7 @@ import { Typography } from '@mui/material'; import * as React from 'react'; -export const ComponentError: React.FC<{ text: string }> = ({ text }) => ( +export const ComponentError: FCWithChildren<{ text: string }> = ({ text }) => ( = ({ +export const ContentCard: FCWithChildren = ({ title, Icon, Action, diff --git a/explorer/src/components/CustomColumnHeading.tsx b/explorer/src/components/CustomColumnHeading.tsx index 4adcda4540..c15ef27f9b 100644 --- a/explorer/src/components/CustomColumnHeading.tsx +++ b/explorer/src/components/CustomColumnHeading.tsx @@ -4,7 +4,7 @@ import { ExpandLess, ExpandMore } from '@mui/icons-material'; import { useTheme } from '@mui/material/styles'; import { Tooltip } from '@nymproject/react/tooltip/Tooltip'; -export const CustomColumnHeading: React.FC<{ headingTitle: string; tooltipInfo?: string }> = ({ +export const CustomColumnHeading: FCWithChildren<{ headingTitle: string; tooltipInfo?: string }> = ({ headingTitle, tooltipInfo, }) => { diff --git a/explorer/src/components/DetailTable.tsx b/explorer/src/components/DetailTable.tsx index 75aaae36ab..17418de4f3 100644 --- a/explorer/src/components/DetailTable.tsx +++ b/explorer/src/components/DetailTable.tsx @@ -43,7 +43,7 @@ function formatCellValues(val: string | number, field: string) { return val; } -export const DetailTable: React.FC<{ +export const DetailTable: FCWithChildren<{ tableName: string; columnsData: ColumnsType[]; rows: MixnodeRowType[] | GatewayEnrichedRowType[]; diff --git a/explorer/src/components/Footer.tsx b/explorer/src/components/Footer.tsx index 2ee7c77198..c85ba47be4 100644 --- a/explorer/src/components/Footer.tsx +++ b/explorer/src/components/Footer.tsx @@ -4,7 +4,7 @@ import { Typography } from '@mui/material'; import { Socials } from './Socials'; import { useIsMobile } from '../hooks/useIsMobile'; -export const Footer: React.FC = () => { +export const Footer: FCWithChildren = () => { const isMobile = useIsMobile(); return ( diff --git a/explorer/src/components/MixNodes/BondBreakdown.tsx b/explorer/src/components/MixNodes/BondBreakdown.tsx index 06009be05d..d7faa163fc 100644 --- a/explorer/src/components/MixNodes/BondBreakdown.tsx +++ b/explorer/src/components/MixNodes/BondBreakdown.tsx @@ -13,7 +13,7 @@ import { currencyToString } from '../../utils/currency'; import { useMixnodeContext } from '../../context/mixnode'; import { useIsMobile } from '../../hooks/useIsMobile'; -export const BondBreakdownTable: React.FC = () => { +export const BondBreakdownTable: FCWithChildren = () => { const { mixNode, delegations, uniqDelegations } = useMixnodeContext(); const [showDelegations, toggleShowDelegations] = React.useState(false); diff --git a/explorer/src/components/MixNodes/DetailSection.tsx b/explorer/src/components/MixNodes/DetailSection.tsx index b338487fd2..dcf0f830b5 100644 --- a/explorer/src/components/MixNodes/DetailSection.tsx +++ b/explorer/src/components/MixNodes/DetailSection.tsx @@ -11,7 +11,7 @@ interface MixNodeDetailProps { mixnodeDescription: MixNodeDescriptionResponse; } -export const MixNodeDetailSection: React.FC = ({ mixNodeRow, mixnodeDescription }) => { +export const MixNodeDetailSection: FCWithChildren = ({ mixNodeRow, mixnodeDescription }) => { const theme = useTheme(); const palette = [theme.palette.text.primary]; const isMobile = useIsMobile(); diff --git a/explorer/src/components/MixNodes/Economics/EconomicsProgress.tsx b/explorer/src/components/MixNodes/Economics/EconomicsProgress.tsx index 1779d8d18f..9f8525a754 100644 --- a/explorer/src/components/MixNodes/Economics/EconomicsProgress.tsx +++ b/explorer/src/components/MixNodes/Economics/EconomicsProgress.tsx @@ -6,7 +6,7 @@ import { Box } from '@mui/system'; const parseToNumber = (value: number | undefined | string) => typeof value === 'string' ? parseInt(value || '', 10) : value || 0; -export const EconomicsProgress: React.FC< +export const EconomicsProgress: FCWithChildren< LinearProgressProps & { threshold?: number; } diff --git a/explorer/src/components/MixNodes/Economics/Table.tsx b/explorer/src/components/MixNodes/Economics/Table.tsx index 5977847436..929445254a 100644 --- a/explorer/src/components/MixNodes/Economics/Table.tsx +++ b/explorer/src/components/MixNodes/Economics/Table.tsx @@ -66,7 +66,7 @@ const formatCellValues = (value: EconomicsRowsType, field: string) => { ); }; -export const DelegatorsInfoTable: React.FC> = ({ +export const DelegatorsInfoTable: FCWithChildren> = ({ tableName, columnsData, rows, diff --git a/explorer/src/components/MixNodes/Status.tsx b/explorer/src/components/MixNodes/Status.tsx index 88cfe6c1eb..a2da302c87 100644 --- a/explorer/src/components/MixNodes/Status.tsx +++ b/explorer/src/components/MixNodes/Status.tsx @@ -36,7 +36,7 @@ export const getMixNodeStatusText = (status: MixnodeStatus) => { } }; -export const MixNodeStatus: React.FC = ({ status }) => { +export const MixNodeStatus: FCWithChildren = ({ status }) => { const theme = useTheme(); const Icon = React.useMemo(() => getMixNodeIcon(status), [status]); const color = React.useMemo(() => getMixNodeStatusColor(theme, status), [status, theme]); diff --git a/explorer/src/components/MixNodes/StatusDropdown.tsx b/explorer/src/components/MixNodes/StatusDropdown.tsx index 18263edf6e..9cb34a2f0c 100644 --- a/explorer/src/components/MixNodes/StatusDropdown.tsx +++ b/explorer/src/components/MixNodes/StatusDropdown.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { MenuItem } from '@mui/material'; import Select from '@mui/material/Select'; -import { SelectInputProps } from '@mui/material/Select/SelectInput'; +import { SelectChangeEvent } from '@mui/material/Select/SelectInput'; import { SxProps } from '@mui/system'; import { MixNodeStatus } from './Status'; import { MixnodeStatus, MixnodeStatusWithAll } from '../../typeDefs/explorer-api'; @@ -16,14 +16,18 @@ interface MixNodeStatusDropdownProps { onSelectionChanged?: (status?: MixnodeStatusWithAll) => void; } -export const MixNodeStatusDropdown: React.FC = ({ status, onSelectionChanged, sx }) => { +export const MixNodeStatusDropdown: FCWithChildren = ({ + status, + onSelectionChanged, + sx, +}) => { const isMobile = useIsMobile(); const [statusValue, setStatusValue] = React.useState(status || MixnodeStatusWithAll.all); - const onChange: SelectInputProps['onChange'] = React.useCallback( - ({ target: { value } }) => { - setStatusValue(value); + const onChange = React.useCallback( + (event: SelectChangeEvent) => { + setStatusValue(event.target.value as MixnodeStatusWithAll); if (onSelectionChanged) { - onSelectionChanged(value); + onSelectionChanged(event.target.value as MixnodeStatusWithAll); } }, [onSelectionChanged], diff --git a/explorer/src/components/MobileNav.tsx b/explorer/src/components/MobileNav.tsx index cb44210e9d..ac03cb9c80 100644 --- a/explorer/src/components/MobileNav.tsx +++ b/explorer/src/components/MobileNav.tsx @@ -25,11 +25,7 @@ import { NYM_WEBSITE } from '../api/constants'; import { ExpandableButton } from './Nav'; import { DarkLightSwitchMobile } from './Switch'; -type MobileNavProps = { - children: React.ReactNode; -}; - -export const MobileNav: React.FC<{ children: React.ReactNode }> = ({ children }: MobileNavProps) => { +export const MobileNav: FCWithChildren = ({ children }) => { const theme = useTheme(); const { navState, updateNavState } = useMainContext(); const [drawerOpen, setDrawerOpen] = React.useState(false); diff --git a/explorer/src/components/Nav.tsx b/explorer/src/components/Nav.tsx index e2808871a0..2461263ff5 100644 --- a/explorer/src/components/Nav.tsx +++ b/explorer/src/components/Nav.tsx @@ -87,7 +87,7 @@ type ExpandableButtonType = { setToActive: (num: number) => void; }; -export const ExpandableButton: React.FC = ({ +export const ExpandableButton: FCWithChildren = ({ id, url, setToActive, @@ -230,7 +230,7 @@ ExpandableButton.defaultProps = { closeDrawer: undefined, }; -export const Nav: React.FC = ({ children }) => { +export const Nav: FCWithChildren = ({ children }) => { const { updateNavState, navState } = useMainContext(); const [drawerIsOpen, setDrawerToOpen] = React.useState(false); const [fixedOpen, setFixedOpen] = React.useState(false); diff --git a/explorer/src/components/Socials.tsx b/explorer/src/components/Socials.tsx index f359a24ac1..138b0e18eb 100644 --- a/explorer/src/components/Socials.tsx +++ b/explorer/src/components/Socials.tsx @@ -12,7 +12,7 @@ export const TWITTER_LINK = 'https://twitter.com/nymproject'; export const GITHUB_LINK = 'https://github.com/nymtech'; export const DISCORD_LINK = 'https://discord.gg/nym'; -export const Socials: React.FC<{ isFooter?: boolean }> = ({ isFooter }) => { +export const Socials: FCWithChildren<{ isFooter?: boolean }> = ({ isFooter }) => { const theme = useTheme(); const color = isFooter ? theme.palette.nym.networkExplorer.footer.socialIcons diff --git a/explorer/src/components/StatsCard.tsx b/explorer/src/components/StatsCard.tsx index a571441015..36355b1759 100644 --- a/explorer/src/components/StatsCard.tsx +++ b/explorer/src/components/StatsCard.tsx @@ -11,7 +11,14 @@ interface StatsCardProps { onClick?: () => void; color?: string; } -export const StatsCard: React.FC = ({ icon, title, count, onClick, errorMsg, color: colorProp }) => { +export const StatsCard: FCWithChildren = ({ + icon, + title, + count, + onClick, + errorMsg, + color: colorProp, +}) => { const theme = useTheme(); const color = colorProp || theme.palette.text.primary; return ( diff --git a/explorer/src/components/Switch.tsx b/explorer/src/components/Switch.tsx index 835100a1db..e5cbd47385 100644 --- a/explorer/src/components/Switch.tsx +++ b/explorer/src/components/Switch.tsx @@ -51,7 +51,7 @@ export const DarkLightSwitch = styled(Switch)(({ theme }) => ({ }, })); -export const DarkLightSwitchMobile: React.FC = () => { +export const DarkLightSwitchMobile: FCWithChildren = () => { const { toggleMode } = useMainContext(); return ( diff --git a/ts-packages/react-components/src/playground/checkboxes.tsx b/ts-packages/react-components/src/playground/checkboxes.tsx index 90a020e2e0..a903fc1f59 100644 --- a/ts-packages/react-components/src/playground/checkboxes.tsx +++ b/ts-packages/react-components/src/playground/checkboxes.tsx @@ -3,7 +3,7 @@ import Checkbox from '@mui/material/Checkbox'; const label = { inputProps: { 'aria-label': 'Checkbox demo' } }; -export const PlaygroundCheckboxes: React.FC = () => ( +export const PlaygroundCheckboxes: FCWithChildren = () => (
diff --git a/ts-packages/react-components/src/playground/fonts.tsx b/ts-packages/react-components/src/playground/fonts.tsx index 5bbd822905..a7347c0191 100644 --- a/ts-packages/react-components/src/playground/fonts.tsx +++ b/ts-packages/react-components/src/playground/fonts.tsx @@ -4,7 +4,7 @@ const CONTENT = 'The quick brown fox jumped over the white fence'; const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]; -export const PlaygroundFonts: React.FC = () => ( +export const PlaygroundFonts: FCWithChildren = () => (
{WEIGHTS.map((fontWeight) => (
diff --git a/ts-packages/react-components/src/playground/switches.tsx b/ts-packages/react-components/src/playground/switches.tsx index edda1654a9..dde14e1e2b 100644 --- a/ts-packages/react-components/src/playground/switches.tsx +++ b/ts-packages/react-components/src/playground/switches.tsx @@ -3,7 +3,7 @@ import Switch from '@mui/material/Switch'; const label = { inputProps: { 'aria-label': 'Switch demo' } }; -export const PlaygroundBasicSwitches: React.FC = () => ( +export const PlaygroundBasicSwitches: FCWithChildren = () => (
diff --git a/ts-packages/react-components/src/playground/theme.tsx b/ts-packages/react-components/src/playground/theme.tsx index 609dd86aa9..8bab62e51b 100644 --- a/ts-packages/react-components/src/playground/theme.tsx +++ b/ts-packages/react-components/src/playground/theme.tsx @@ -3,7 +3,7 @@ import { useTheme } from '@mui/material'; import { MUIThemeExplorer } from './theme/MUIThemeExplorer'; import { PaletteSwatches, PaletteSwatchesList } from './theme/PaletteSwatches'; -export const PlaygroundTheme: React.FC = () => { +export const PlaygroundTheme: FCWithChildren = () => { const theme = useTheme(); return ( <> @@ -15,7 +15,7 @@ export const PlaygroundTheme: React.FC = () => { ); }; -export const PlaygroundPalette: React.FC = () => { +export const PlaygroundPalette: FCWithChildren = () => { const theme = useTheme(); return ; }; diff --git a/ts-packages/react-components/src/playground/theme/MUIThemeExplorer.tsx b/ts-packages/react-components/src/playground/theme/MUIThemeExplorer.tsx index e395969a72..82b64dae9c 100644 --- a/ts-packages/react-components/src/playground/theme/MUIThemeExplorer.tsx +++ b/ts-packages/react-components/src/playground/theme/MUIThemeExplorer.tsx @@ -7,7 +7,7 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import ArrowRightIcon from '@mui/icons-material/ArrowRight'; import { Box } from '@mui/material'; -const MUIThemeExplorerItem: React.FC<{ +const MUIThemeExplorerItem: FCWithChildren<{ path: string; parentKey: string; theme: Theme; @@ -82,7 +82,7 @@ const MUIThemeExplorerItem: React.FC<{ return null; }; -export const MUIThemeExplorer: React.FC<{ +export const MUIThemeExplorer: FCWithChildren<{ theme: Theme; }> = ({ theme }) => ( ); -export const PaletteSwatches: React.FC<{ +export const PaletteSwatches: FCWithChildren<{ theme: Theme; }> = ({ theme }) => { const swatches = React.useMemo(() => flatten(theme.palette), [theme.palette]); @@ -46,7 +46,7 @@ export const PaletteSwatches: React.FC<{ ); }; -export const PaletteSwatchesList: React.FC<{ +export const PaletteSwatchesList: FCWithChildren<{ theme: Theme; }> = ({ theme }) => { const swatches = React.useMemo(() => flatten(theme.palette), [theme.palette]); diff --git a/ts-packages/react-components/src/typings/FC.d.ts b/ts-packages/react-components/src/typings/FC.d.ts new file mode 100644 index 0000000000..08ebdfa298 --- /dev/null +++ b/ts-packages/react-components/src/typings/FC.d.ts @@ -0,0 +1 @@ +declare type FCWithChildren

= React.FC>; diff --git a/ts-packages/react-webpack-with-theme-example/README.md b/ts-packages/react-webpack-with-theme-example/README.md index 37a3029f11..a95d916957 100644 --- a/ts-packages/react-webpack-with-theme-example/README.md +++ b/ts-packages/react-webpack-with-theme-example/README.md @@ -51,7 +51,7 @@ Storybook is available in [@nymproject/react](../react-components/src/stories/In The [Nym theme](../mui-theme/src/theme/theme.ts) provides a theme provider that you can add as follows: ```typescript jsx -export const App: React.FC = () => ( +export const App: FCWithChildren = () => ( @@ -59,13 +59,13 @@ export const App: React.FC = () => ( ); -export const AppTheme: React.FC = ({ children }) => { +export const AppTheme: FCWithChildren = ({ children }) => { const { mode } = useAppContext(); return {children}; }; -export const Content: React.FC = () => { +export const Content: FCWithChildren = () => { ... } ``` diff --git a/ts-packages/react-webpack-with-theme-example/package.json b/ts-packages/react-webpack-with-theme-example/package.json index fc05cce9c6..078ebc27cb 100644 --- a/ts-packages/react-webpack-with-theme-example/package.json +++ b/ts-packages/react-webpack-with-theme-example/package.json @@ -4,8 +4,8 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "@mui/material": "^5.0.1", "@mui/styles": "^5.0.1", "@mui/icons-material": "^5.5.0", @@ -27,7 +27,7 @@ "@testing-library/react": "^12.0.0", "@types/jest": "^27.0.1", "@types/node": "^16.7.13", - "@types/react": "^17.0.34", + "@types/react": "^18.0.26", "@typescript-eslint/eslint-plugin": "^5.13.0", "@typescript-eslint/parser": "^5.13.0", "babel-loader": "^8.3.0", diff --git a/ts-packages/react-webpack-with-theme-example/src/App.tsx b/ts-packages/react-webpack-with-theme-example/src/App.tsx index 80ca1cc33a..6f70787807 100644 --- a/ts-packages/react-webpack-with-theme-example/src/App.tsx +++ b/ts-packages/react-webpack-with-theme-example/src/App.tsx @@ -8,13 +8,13 @@ import { useTheme } from '@mui/material/styles'; import { ThemeToggle } from './ThemeToggle'; import { AppContextProvider, useAppContext } from './context'; -export const AppTheme: React.FC = ({ children }) => { +export const AppTheme: FCWithChildren = ({ children }) => { const { mode } = useAppContext(); return {children}; }; -export const Content: React.FC = () => { +export const Content: FCWithChildren = () => { const { mode } = useAppContext(); const theme = useTheme(); const isMounted = useIsMounted(); @@ -70,7 +70,7 @@ export const Content: React.FC = () => { ); }; -export const App: React.FC = () => ( +export const App: FCWithChildren = () => ( diff --git a/ts-packages/react-webpack-with-theme-example/src/ThemeToggle.tsx b/ts-packages/react-webpack-with-theme-example/src/ThemeToggle.tsx index e52ed5dce5..2739f429e9 100644 --- a/ts-packages/react-webpack-with-theme-example/src/ThemeToggle.tsx +++ b/ts-packages/react-webpack-with-theme-example/src/ThemeToggle.tsx @@ -4,7 +4,7 @@ import DarkModeIcon from '@mui/icons-material/DarkMode'; import LightModeIcon from '@mui/icons-material/LightMode'; import { useAppContext } from './context'; -export const ThemeToggle: React.FC = () => { +export const ThemeToggle: FCWithChildren = () => { const { mode, toggleMode } = useAppContext(); return (