From 2eee5195ccf006b5805e1b637605df2e5139ea8c Mon Sep 17 00:00:00 2001 From: Fouad Date: Thu, 12 Jan 2023 17:15:31 +0000 Subject: [PATCH] React / React DOM / Types upgrade to version 18 (#2830) * new react and reactdom packages in wallet * new react and reactdom packages in root * new react and reactdom packages in nym connect * new react and reactdom packages in root * update react and reactdom for explorer * react and react-dom upgrade for ts-packages remove unused import fix linting error * use custom FC typing move typings folder * fix type error --- explorer/package.json | 8 +-- explorer/src/App.tsx | 2 +- explorer/src/components/ComponentError.tsx | 2 +- explorer/src/components/ContentCard.tsx | 2 +- .../src/components/CustomColumnHeading.tsx | 2 +- explorer/src/components/DetailTable.tsx | 2 +- explorer/src/components/Footer.tsx | 2 +- .../src/components/MixNodes/BondBreakdown.tsx | 2 +- .../src/components/MixNodes/DetailSection.tsx | 2 +- .../MixNodes/Economics/EconomicsProgress.tsx | 2 +- .../components/MixNodes/Economics/Table.tsx | 2 +- explorer/src/components/MixNodes/Status.tsx | 2 +- .../components/MixNodes/StatusDropdown.tsx | 16 +++--- explorer/src/components/MobileNav.tsx | 6 +-- explorer/src/components/Nav.tsx | 4 +- explorer/src/components/Socials.tsx | 2 +- explorer/src/components/StatsCard.tsx | 9 +++- explorer/src/components/Switch.tsx | 4 +- explorer/src/components/TableToolbar.tsx | 2 +- explorer/src/components/Title.tsx | 2 +- explorer/src/components/TwoColSmallTable.tsx | 2 +- .../src/components/Universal-DataGrid.tsx | 2 +- explorer/src/components/UptimeChart.tsx | 2 +- explorer/src/components/WorldMap.tsx | 2 +- explorer/src/context/main.tsx | 2 +- explorer/src/context/mixnode.tsx | 3 +- explorer/src/errors/ErrorBoundaryContent.tsx | 2 +- explorer/src/icons/GatewaysSVG.tsx | 2 +- explorer/src/icons/LightSwitchSVG.tsx | 2 +- explorer/src/icons/MixnodesSVG.tsx | 2 +- explorer/src/icons/MobileDrawerClose.tsx | 2 +- explorer/src/icons/NetworksSVG.tsx | 2 +- explorer/src/icons/NodemapSVG.tsx | 2 +- explorer/src/icons/OverviewSVG.tsx | 2 +- explorer/src/icons/ValidatorsSVG.tsx | 2 +- explorer/src/icons/socials/DiscordIcon.tsx | 2 +- explorer/src/icons/socials/GitHubIcon.tsx | 2 +- explorer/src/icons/socials/TelegramIcon.tsx | 2 +- explorer/src/icons/socials/TwitterIcon.tsx | 2 +- explorer/src/index.tsx | 30 +++++++----- explorer/src/pages/404/index.tsx | 2 +- explorer/src/pages/GatewayDetail/index.tsx | 4 +- explorer/src/pages/Gateways/index.tsx | 2 +- explorer/src/pages/MixnodeDetail/index.tsx | 6 +-- explorer/src/pages/Mixnodes/index.tsx | 2 +- explorer/src/pages/MixnodesMap/index.tsx | 9 +++- explorer/src/pages/Overview/index.tsx | 2 +- explorer/src/routes/index.tsx | 4 +- explorer/src/routes/network-components.tsx | 4 +- explorer/src/theme/index.tsx | 2 +- explorer/src/typings/FC.d.ts | 1 + nym-connect/package.json | 8 +-- nym-connect/src/App.tsx | 2 +- nym-connect/src/components/AppWindowFrame.tsx | 2 +- .../src/components/ConnectionButton.tsx | 2 +- .../src/components/ConnectionStats.tsx | 2 +- .../src/components/ConnectionStatus.tsx | 4 +- .../Growth/TestAndEarnButtonArea.tsx | 4 +- .../Growth/TestAndEarnCurrentDraw.tsx | 10 ++-- .../components/Growth/TestAndEarnDraws.tsx | 6 +-- .../Growth/TestAndEarnEnterWalletAddress.tsx | 2 +- .../components/Growth/TestAndEarnError.tsx | 2 +- .../Growth/TestAndEarnPopup.stories.tsx | 14 +++--- .../components/Growth/TestAndEarnPopup.tsx | 4 +- .../components/Growth/TestAndEarnTakePart.tsx | 2 +- .../components/Growth/TestAndEarnWinner.tsx | 4 +- .../Growth/TestAndEarnWinnerWalletAddress.tsx | 2 +- .../Growth/context/TestAndEarnContext.tsx | 2 +- .../context/mocks/TestAndEarnContext.tsx | 14 +++--- .../src/components/IpAddressAndPort.tsx | 2 +- nym-connect/src/components/NeedHelp.tsx | 2 +- .../src/components/ServiceProviderPopup.tsx | 2 +- .../components/ServiceProviderSelector.tsx | 2 +- .../src/components/ServiceSelector.tsx | 2 +- nym-connect/src/context/main.tsx | 2 +- nym-connect/src/context/mocks/main.tsx | 2 +- nym-connect/src/index.tsx | 34 +++++++------ nym-connect/src/layouts/ConnectedLayout.tsx | 2 +- nym-connect/src/layouts/DefaultLayout.tsx | 2 +- nym-connect/src/theme/index.tsx | 4 +- nym-connect/src/typings/FC.d.ts | 1 + nym-wallet/package.json | 8 +-- nym-wallet/src/components/ActionsMenu.tsx | 12 ++--- .../Bonding/modals/BondOversaturatedModal.tsx | 2 +- nym-wallet/src/components/ClientAddress.tsx | 16 ++---- nym-wallet/src/components/ConfirmTX.tsx | 3 +- .../components/Delegation/DelegateBlocker.tsx | 2 +- .../components/Delegation/DelegateModal.tsx | 2 +- .../Delegation/DelegationActions.tsx | 4 +- .../components/Delegation/DelegationList.tsx | 4 +- .../Delegation/DelegationModal.stories.tsx | 2 +- .../components/Delegation/DelegationModal.tsx | 3 +- .../src/components/Delegation/Delegations.tsx | 2 +- .../components/Delegation/Modals.stories.tsx | 2 +- .../components/Delegation/UndelegateModal.tsx | 2 +- .../src/components/Modals/ErrorModal.tsx | 3 +- .../src/components/Modals/LoadingModal.tsx | 2 +- .../src/components/Modals/ModalDivider.tsx | 2 +- .../src/components/Modals/ModalListItem.tsx | 2 +- .../components/Modals/SimpleModal.stories.tsx | 2 +- .../src/components/Modals/SimpleModal.tsx | 3 +- nym-wallet/src/components/NetworkSelector.tsx | 2 +- nym-wallet/src/components/NymCard.tsx | 3 +- .../Rewards/RedeemModal.stories.tsx | 2 +- .../src/components/Rewards/RedeemModal.tsx | 2 +- .../src/components/Rewards/RewardsSummary.tsx | 2 +- nym-wallet/src/components/SuccessResponse.tsx | 2 +- nym-wallet/src/components/Title.tsx | 2 +- .../src/components/TokenPoolSelector.tsx | 2 +- .../src/components/TransactionDetails.tsx | 2 +- nym-wallet/src/components/textfields.tsx | 4 +- nym-wallet/src/context/accounts.tsx | 2 +- nym-wallet/src/context/auth.tsx | 2 +- nym-wallet/src/context/bonding.tsx | 2 +- nym-wallet/src/context/buy.tsx | 2 +- nym-wallet/src/context/delegations.tsx | 1 + nym-wallet/src/context/main.tsx | 2 +- nym-wallet/src/context/mocks/accounts.tsx | 2 +- nym-wallet/src/context/mocks/buy.tsx | 2 +- nym-wallet/src/context/mocks/delegations.tsx | 2 +- nym-wallet/src/context/mocks/main.tsx | 2 +- nym-wallet/src/context/mocks/rewards.tsx | 2 +- nym-wallet/src/context/rewards.tsx | 2 +- nym-wallet/src/index.tsx | 9 ++-- nym-wallet/src/layouts/AppLayout.tsx | 2 +- nym-wallet/src/layouts/AuthLayout.tsx | 2 +- nym-wallet/src/layouts/PageLayout.tsx | 5 +- nym-wallet/src/pages/Admin/index.tsx | 4 +- nym-wallet/src/pages/auth/pages/welcome.tsx | 2 +- .../balance/components/vesting-timeline.tsx | 4 +- .../src/pages/internal-docs/DocEntry.tsx | 2 +- nym-wallet/src/pages/settings/tabs.tsx | 4 +- nym-wallet/src/pages/terminal/index.tsx | 7 +-- nym-wallet/src/svg-icons/node.tsx | 2 +- nym-wallet/src/theme/NymWalletTheme.tsx | 5 +- nym-wallet/src/theme/index.tsx | 4 +- nym-wallet/src/typings/FC.d.ts | 1 + .../package.json | 7 +-- .../src/App.tsx | 6 +-- .../src/ThemeToggle.tsx | 2 +- .../src/context/index.tsx | 2 +- .../src/context/mixnet.tsx | 2 +- testnet-faucet/package.json | 4 +- testnet-faucet/src/context/index.tsx | 5 +- testnet-faucet/src/theme/index.tsx | 2 +- testnet-faucet/typings/FC.d.ts | 1 + .../package.json | 4 +- ts-packages/mui-theme/README.md | 8 +-- ts-packages/mui-theme/package.json | 6 +-- ts-packages/mui-theme/src/theme/index.tsx | 10 +++- ts-packages/mui-theme/src/typings/FC.d.ts | 1 + ts-packages/react-components/package.json | 19 ++++--- .../account/WalletAddressFormField.tsx | 2 +- .../components/clipboard/CopyToClipboard.tsx | 2 +- .../src/components/coins/CoinMark.tsx | 2 +- .../src/components/coins/CoinMarkTestnet.tsx | 2 +- .../src/components/currency/Currency.tsx | 2 +- .../components/currency/CurrencyAmount.tsx | 4 +- .../components/currency/CurrencyFormField.tsx | 2 +- .../currency/CurrencyWithCoinMark.tsx | 2 +- .../src/components/logo/NymIcon.tsx | 2 +- .../src/components/logo/NymLogo.tsx | 2 +- .../src/components/logo/NymWordmark.tsx | 2 +- .../mixnodes/IdentityKeyFormField.tsx | 2 +- .../components/networks/NetworkSelector.tsx | 4 +- .../src/playground/Playground.tsx | 2 +- .../src/playground/buttons.tsx | 4 +- .../src/playground/checkboxes.tsx | 2 +- .../react-components/src/playground/fonts.tsx | 2 +- .../src/playground/switches.tsx | 2 +- .../react-components/src/playground/theme.tsx | 4 +- .../src/playground/theme/MUIThemeExplorer.tsx | 4 +- .../src/playground/theme/PaletteSwatches.tsx | 6 +-- .../react-components/src/typings/FC.d.ts | 1 + .../README.md | 6 +-- .../package.json | 6 +-- .../src/App.tsx | 6 +-- .../src/ThemeToggle.tsx | 2 +- .../src/context/index.tsx | 2 +- .../src/typings/FC.d.ts | 1 + .../yarn-error.log | 4 +- ts-packages/webpack/package.json | 4 +- yarn.lock | 49 ++++++++++++------- 183 files changed, 392 insertions(+), 326 deletions(-) create mode 100644 explorer/src/typings/FC.d.ts create mode 100644 nym-connect/src/typings/FC.d.ts create mode 100644 nym-wallet/src/typings/FC.d.ts create mode 100644 testnet-faucet/typings/FC.d.ts create mode 100644 ts-packages/mui-theme/src/typings/FC.d.ts create mode 100644 ts-packages/react-components/src/typings/FC.d.ts create mode 100644 ts-packages/react-webpack-with-theme-example/src/typings/FC.d.ts 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 (