Fix types for react 18

This commit is contained in:
Willian Mitsuda 2022-08-06 23:32:08 -03:00
parent 2acadc7d00
commit 8ad1c7186b
14 changed files with 71 additions and 57 deletions

View File

@ -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<StepProps> = React.memo(({ type, msg, children }) => (
<>
<div className="flex space-x-2">
{type === "wait" && (
<span className="text-gray-600">
<FontAwesomeIcon icon={faClock} size="1x" />
</span>
)}
{type === "ok" && (
<span className="text-green-600">
<FontAwesomeIcon icon={faCheckCircle} size="1x" />
</span>
)}
{type === "error" && (
<span className="text-red-600">
<FontAwesomeIcon icon={faTimesCircle} size="1x" />
</span>
)}
<span>{msg}</span>
</div>
{children && <div className="ml-7 mt-4 text-sm">{children}</div>}
</>
));
const Step: React.FC<PropsWithChildren<StepProps>> = React.memo(
({ type, msg, children }) => (
<>
<div className="flex space-x-2">
{type === "wait" && (
<span className="text-gray-600">
<FontAwesomeIcon icon={faClock} size="1x" />
</span>
)}
{type === "ok" && (
<span className="text-green-600">
<FontAwesomeIcon icon={faCheckCircle} size="1x" />
</span>
)}
{type === "error" && (
<span className="text-red-600">
<FontAwesomeIcon icon={faTimesCircle} size="1x" />
</span>
)}
<span>{msg}</span>
</div>
{children && <div className="ml-7 mt-4 text-sm">{children}</div>}
</>
)
);
export default React.memo(ConnectionErrorPanel);

View File

@ -1,10 +1,13 @@
import React from "react";
import React, { PropsWithChildren } from "react";
type ContentFrameProps = {
tabs?: boolean;
};
const ContentFrame: React.FC<ContentFrameProps> = ({ tabs, children }) => {
const ContentFrame: React.FC<PropsWithChildren<ContentFrameProps>> = ({
tabs,
children,
}) => {
return tabs ? (
<div className="divide-y border rounded-b-lg px-3 bg-white">{children}</div>
) : (

View File

@ -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<SourcifyMenuItemProps> = ({
const SourcifyMenuItem: React.FC<PropsWithChildren<SourcifyMenuItemProps>> = ({
checked = false,
onClick,
children,

View File

@ -1,6 +1,6 @@
import React from "react";
import React, { PropsWithChildren } from "react";
const StandardFrame: React.FC = ({ children }) => (
const StandardFrame: React.FC<PropsWithChildren> = ({ children }) => (
<div className="flex-grow bg-gray-100 px-9 pt-3 pb-12">{children}</div>
);

View File

@ -1,6 +1,6 @@
import React from "react";
import React, { PropsWithChildren } from "react";
const StandardSubtitle: React.FC = ({ children }) => (
const StandardSubtitle: React.FC<PropsWithChildren> = ({ children }) => (
<div className="pb-2 text-xl text-gray-700">{children}</div>
);

View File

@ -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<NavButtonProps> = ({
const NavButton: React.FC<PropsWithChildren<NavButtonProps>> = ({
blockNum,
disabled,
urlBuilder,

View File

@ -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<AddressLegendProps> = ({ title, children }) => (
const AddressLegend: React.FC<PropsWithChildren<AddressLegendProps>> = ({
title,
children,
}) => (
<span
className="text-xs text-gray-400 text-opacity-70 not-italic"
title={title}

View File

@ -1,4 +1,4 @@
import React from "react";
import React, { PropsWithChildren } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons/faExternalLinkAlt";
@ -6,7 +6,10 @@ type ExternalLinkProps = {
href: string;
};
const ExternalLink: React.FC<ExternalLinkProps> = ({ href, children }) => (
const ExternalLink: React.FC<PropsWithChildren<ExternalLinkProps>> = ({
href,
children,
}) => (
<a
className="text-link-blue hover:text-link-blue-hover"
href={href}

View File

@ -1,11 +1,14 @@
import React from "react";
import React, { PropsWithChildren } from "react";
import { Tab } from "@headlessui/react";
type ModeTabProps = {
disabled?: boolean | undefined;
};
const ModeTab: React.FC<ModeTabProps> = ({ disabled, children }) => (
const ModeTab: React.FC<PropsWithChildren<ModeTabProps>> = ({
disabled,
children,
}) => (
<Tab
className={({ selected }) =>
`border rounded-lg px-2 py-1 bg-gray-100 ${

View File

@ -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<NavTabProps> = ({ href, children }) => (
const NavTab: React.FC<PropsWithChildren<NavTabProps>> = ({
href,
children,
}) => (
<Tab as={Fragment}>
<NavLink
className={({ isActive }) =>

View File

@ -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<HighlighterBoxProps> = React.memo(
({ selected, select, deselect, children }) => (
const HighlighterBox: React.FC<PropsWithChildren<HighlighterBoxProps>> =
React.memo(({ selected, select, deselect, children }) => (
<div
className={`border border-dashed rounded hover:bg-transparent hover:border-transparent px-1 truncate ${
selected ? "border-orange-400 bg-yellow-100" : "border-transparent"
@ -73,7 +73,6 @@ const HighlighterBox: React.FC<HighlighterBoxProps> = React.memo(
>
{children}
</div>
)
);
));
export default SelectionHighlighter;

View File

@ -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<PageButtonProps> = ({
const PageButton: React.FC<PropsWithChildren<PageButtonProps>> = ({
goToPage,
disabled,
children,

View File

@ -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<UndefinedPageButtonProps> = ({
address,
direction,
hash,
disabled,
children,
}) => {
const UndefinedPageButton: React.FC<
PropsWithChildren<UndefinedPageButtonProps>
> = ({ address, direction, hash, disabled, children }) => {
if (disabled) {
return (
<span className="bg-link-blue bg-opacity-10 text-gray-400 rounded-lg px-3 py-2 text-xs">

View File

@ -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<NavButtonProps> = ({
const NavButton: React.FC<PropsWithChildren<NavButtonProps>> = ({
sender,
nonce,
disabled,