From 8ad1c7186b17e44fc15132ea3e381deff26888e4 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 6 Aug 2022 23:32:08 -0300 Subject: [PATCH] Fix types for react 18 --- src/ConnectionErrorPanel.tsx | 50 +++++++++++++------------ src/ContentFrame.tsx | 7 +++- src/SourcifyMenu.tsx | 4 +- src/StandardFrame.tsx | 4 +- src/StandardSubtitle.tsx | 4 +- src/block/NavButton.tsx | 3 +- src/components/DecoratedAddressLink.tsx | 7 +++- src/components/ExternalLink.tsx | 7 +++- src/components/ModeTab.tsx | 7 +++- src/components/NavTab.tsx | 7 +++- src/components/SelectionHighlighter.tsx | 9 ++--- src/search/PageButton.tsx | 4 +- src/search/UndefinedPageButton.tsx | 12 ++---- src/transaction/NavButton.tsx | 3 +- 14 files changed, 71 insertions(+), 57 deletions(-) diff --git a/src/ConnectionErrorPanel.tsx b/src/ConnectionErrorPanel.tsx index 80a8205..fb65cf1 100644 --- a/src/ConnectionErrorPanel.tsx +++ b/src/ConnectionErrorPanel.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faClock } from "@fortawesome/free-solid-svg-icons/faClock"; import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle"; @@ -90,28 +90,30 @@ type StepProps = { msg: string; }; -const Step: React.FC = React.memo(({ type, msg, children }) => ( - <> -
- {type === "wait" && ( - - - - )} - {type === "ok" && ( - - - - )} - {type === "error" && ( - - - - )} - {msg} -
- {children &&
{children}
} - -)); +const Step: React.FC> = React.memo( + ({ type, msg, children }) => ( + <> +
+ {type === "wait" && ( + + + + )} + {type === "ok" && ( + + + + )} + {type === "error" && ( + + + + )} + {msg} +
+ {children &&
{children}
} + + ) +); export default React.memo(ConnectionErrorPanel); diff --git a/src/ContentFrame.tsx b/src/ContentFrame.tsx index 04c9412..7e57c09 100644 --- a/src/ContentFrame.tsx +++ b/src/ContentFrame.tsx @@ -1,10 +1,13 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; type ContentFrameProps = { tabs?: boolean; }; -const ContentFrame: React.FC = ({ tabs, children }) => { +const ContentFrame: React.FC> = ({ + tabs, + children, +}) => { return tabs ? (
{children}
) : ( diff --git a/src/SourcifyMenu.tsx b/src/SourcifyMenu.tsx index 7c614f0..ce23472 100644 --- a/src/SourcifyMenu.tsx +++ b/src/SourcifyMenu.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; import { Menu } from "@headlessui/react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faBars } from "@fortawesome/free-solid-svg-icons/faBars"; @@ -41,7 +41,7 @@ type SourcifyMenuItemProps = { onClick: () => void; }; -const SourcifyMenuItem: React.FC = ({ +const SourcifyMenuItem: React.FC> = ({ checked = false, onClick, children, diff --git a/src/StandardFrame.tsx b/src/StandardFrame.tsx index 10b5fe8..4370cbc 100644 --- a/src/StandardFrame.tsx +++ b/src/StandardFrame.tsx @@ -1,6 +1,6 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; -const StandardFrame: React.FC = ({ children }) => ( +const StandardFrame: React.FC = ({ children }) => (
{children}
); diff --git a/src/StandardSubtitle.tsx b/src/StandardSubtitle.tsx index 21eda81..439eb4f 100644 --- a/src/StandardSubtitle.tsx +++ b/src/StandardSubtitle.tsx @@ -1,6 +1,6 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; -const StandardSubtitle: React.FC = ({ children }) => ( +const StandardSubtitle: React.FC = ({ children }) => (
{children}
); diff --git a/src/block/NavButton.tsx b/src/block/NavButton.tsx index dcdc9a4..96e65e4 100644 --- a/src/block/NavButton.tsx +++ b/src/block/NavButton.tsx @@ -1,3 +1,4 @@ +import { PropsWithChildren } from "react"; import { NavLink } from "react-router-dom"; import { BlockTag } from "@ethersproject/abstract-provider"; import { blockURL } from "../url"; @@ -8,7 +9,7 @@ type NavButtonProps = { urlBuilder?: (blockNumber: BlockTag) => string; }; -const NavButton: React.FC = ({ +const NavButton: React.FC> = ({ blockNum, disabled, urlBuilder, diff --git a/src/components/DecoratedAddressLink.tsx b/src/components/DecoratedAddressLink.tsx index d59ba9d..806d238 100644 --- a/src/components/DecoratedAddressLink.tsx +++ b/src/components/DecoratedAddressLink.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from "react"; +import React, { PropsWithChildren, useContext } from "react"; import { NavLink } from "react-router-dom"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faStar } from "@fortawesome/free-solid-svg-icons/faStar"; @@ -156,7 +156,10 @@ type AddressLegendProps = { title: string; }; -const AddressLegend: React.FC = ({ title, children }) => ( +const AddressLegend: React.FC> = ({ + title, + children, +}) => ( = ({ href, children }) => ( +const ExternalLink: React.FC> = ({ + href, + children, +}) => ( = ({ disabled, children }) => ( +const ModeTab: React.FC> = ({ + disabled, + children, +}) => ( `border rounded-lg px-2 py-1 bg-gray-100 ${ diff --git a/src/components/NavTab.tsx b/src/components/NavTab.tsx index 6b3c66c..768e773 100644 --- a/src/components/NavTab.tsx +++ b/src/components/NavTab.tsx @@ -1,4 +1,4 @@ -import React, { Fragment } from "react"; +import React, { Fragment, PropsWithChildren } from "react"; import { NavLink } from "react-router-dom"; import { Tab } from "@headlessui/react"; @@ -6,7 +6,10 @@ type NavTabProps = { href: string; }; -const NavTab: React.FC = ({ href, children }) => ( +const NavTab: React.FC> = ({ + href, + children, +}) => ( diff --git a/src/components/SelectionHighlighter.tsx b/src/components/SelectionHighlighter.tsx index bebd606..a5a4149 100644 --- a/src/components/SelectionHighlighter.tsx +++ b/src/components/SelectionHighlighter.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from "react"; +import React, { PropsWithChildren, useMemo } from "react"; import { useSelectionContext, OptionalSelection, @@ -62,8 +62,8 @@ type HighlighterBoxProps = { deselect: () => void; }; -const HighlighterBox: React.FC = React.memo( - ({ selected, select, deselect, children }) => ( +const HighlighterBox: React.FC> = + React.memo(({ selected, select, deselect, children }) => (
= React.memo( > {children}
- ) -); + )); export default SelectionHighlighter; diff --git a/src/search/PageButton.tsx b/src/search/PageButton.tsx index 375dc4c..fb6e1f1 100644 --- a/src/search/PageButton.tsx +++ b/src/search/PageButton.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; import { NavLink } from "react-router-dom"; type PageButtonProps = { @@ -6,7 +6,7 @@ type PageButtonProps = { disabled?: boolean; }; -const PageButton: React.FC = ({ +const PageButton: React.FC> = ({ goToPage, disabled, children, diff --git a/src/search/UndefinedPageButton.tsx b/src/search/UndefinedPageButton.tsx index 102fc6d..13cc42f 100644 --- a/src/search/UndefinedPageButton.tsx +++ b/src/search/UndefinedPageButton.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { PropsWithChildren } from "react"; import { NavLink } from "react-router-dom"; type UndefinedPageButtonProps = { @@ -8,13 +8,9 @@ type UndefinedPageButtonProps = { disabled?: boolean; }; -const UndefinedPageButton: React.FC = ({ - address, - direction, - hash, - disabled, - children, -}) => { +const UndefinedPageButton: React.FC< + PropsWithChildren +> = ({ address, direction, hash, disabled, children }) => { if (disabled) { return ( diff --git a/src/transaction/NavButton.tsx b/src/transaction/NavButton.tsx index cad49d2..a274422 100644 --- a/src/transaction/NavButton.tsx +++ b/src/transaction/NavButton.tsx @@ -1,3 +1,4 @@ +import { PropsWithChildren } from "react"; import { NavLink } from "react-router-dom"; import { ChecksummedAddress } from "../types"; import { addressByNonceURL } from "../url"; @@ -9,7 +10,7 @@ type NavButtonProps = { disabled?: boolean; }; -const NavButton: React.FC = ({ +const NavButton: React.FC> = ({ sender, nonce, disabled,