Skip to content

Commit 3e83d04

Browse files
authored
Merge pull request #12014 from TylerAPfledderer/refactor/replace-fc-with-plain-prop-declare
refactor: replace `React.FC` and `interface` with direct declaration and `type`
2 parents cce2945 + aade323 commit 3e83d04

File tree

139 files changed

+477
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+477
-497
lines changed

src/components/BannerGrid/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React from "react"
22
import { Box, Flex, Grid, useToken } from "@chakra-ui/react"
33

4-
export type Props = {
5-
children: React.ReactNode
6-
}
4+
import { ChildOnlyProp } from "@/lib/types"
75

8-
export const Banner: React.FC<Props> = ({ children }) => {
6+
export const Banner = ({ children }: ChildOnlyProp) => {
97
return (
108
<Flex
119
w="full"
@@ -26,23 +24,23 @@ export const Banner: React.FC<Props> = ({ children }) => {
2624
)
2725
}
2826

29-
export const BannerBody: React.FC<Props> = ({ children }) => {
27+
export const BannerBody = ({ children }: ChildOnlyProp) => {
3028
return (
3129
<Box flex={4} p={10}>
3230
{children}
3331
</Box>
3432
)
3533
}
3634

37-
export const BannerImage: React.FC<Props> = ({ children }) => {
35+
export const BannerImage = ({ children }: ChildOnlyProp) => {
3836
return (
3937
<Flex justifyContent="end" flex={2} alignSelf="end">
4038
{children}
4139
</Flex>
4240
)
4341
}
4442

45-
export const BannerGrid: React.FC<Props> = ({ children }) => {
43+
export const BannerGrid = ({ children }: ChildOnlyProp) => {
4644
return (
4745
<Grid
4846
templateColumns={{
@@ -62,7 +60,7 @@ export const BannerGrid: React.FC<Props> = ({ children }) => {
6260
)
6361
}
6462

65-
export const BannerGridCell: React.FC<Props> = ({ children }) => {
63+
export const BannerGridCell = ({ children }: ChildOnlyProp) => {
6664
const [medBp, lgBp] = useToken("breakpoints", ["md", "lg"])
6765

6866
return (

src/components/BannerNotification/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { Center, FlexProps, useMediaQuery } from "@chakra-ui/react"
33

44
import { lightTheme as oldTheme } from "../../theme"
55

6-
export interface IProps extends FlexProps {
6+
export type BannerNotificationProps = FlexProps & {
77
shouldShow?: boolean
88
}
99

10-
const BannerNotification: React.FC<IProps> = ({
10+
const BannerNotification = ({
1111
children,
1212
shouldShow = false,
1313
...props
14-
}) => {
14+
}: BannerNotificationProps) => {
1515
const [isLGScreen] = useMediaQuery(`min-width: ${oldTheme.breakpoints.l}`)
1616
return (
1717
<>

src/components/Banners/BugBountyBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Center, Text } from "@chakra-ui/react"
55
// Components
66
import BannerNotification from "../BannerNotification"
77

8-
const BugBountyBanner: React.FC = () => (
8+
const BugBountyBanner = () => (
99
<BannerNotification shouldShow>
1010
<Center>
1111
<Text m={0} p={0}>

src/components/Banners/DismissableBanner.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import { Center, CloseButton } from "@chakra-ui/react"
66
import BannerNotification from "../BannerNotification"
77

88
// Interface
9-
export interface IProps {
9+
export type DismissableBannerProps = {
1010
children: JSX.Element
1111
storageKey: string
1212
}
1313

14-
const DismissableBanner: React.FC<IProps> = ({ children, storageKey }) => {
14+
const DismissableBanner = ({
15+
children,
16+
storageKey,
17+
}: DismissableBannerProps) => {
1518
const [show, setShow] = useState<boolean>(false)
1619

1720
useEffect(() => {

src/components/Banners/PostMergeBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type { TranslationKey } from "@/lib/types"
66
import BannerNotification from "../BannerNotification"
77
import Translation from "../Translation"
88

9-
export interface IProps {
9+
export type PostMergeBannerProps = {
1010
translationString: TranslationKey
1111
}
1212

13-
const PostMergeBanner: React.FC<IProps> = ({ translationString }) => (
13+
const PostMergeBanner = ({ translationString }: PostMergeBannerProps) => (
1414
<BannerNotification
1515
shouldShow
1616
zIndex={1}

src/components/BeaconChainActions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useTranslation } from "next-i18next"
22
import { Box, Flex } from "@chakra-ui/react"
33

4+
import { ChildOnlyProp } from "@/lib/types"
5+
46
import { ButtonLink } from "@/components/Buttons"
57
import Card from "@/components/Card"
68
import CardList, { type CardListItem } from "@/components/CardList"
@@ -10,7 +12,7 @@ import Translation from "@/components/Translation"
1012
import beaconchain from "@/public/upgrades/beaconchainemoji.png"
1113
import beaconscan from "@/public/upgrades/etherscan.png"
1214

13-
const H3: React.FC<{ children: React.ReactNode }> = ({ children }) => (
15+
const H3 = ({ children }: ChildOnlyProp) => (
1416
<OldHeading
1517
as="h3"
1618
fontSize="2xl"
@@ -22,7 +24,7 @@ const H3: React.FC<{ children: React.ReactNode }> = ({ children }) => (
2224
</OldHeading>
2325
)
2426

25-
const BeaconChainActions: React.FC = () => {
27+
const BeaconChainActions = () => {
2628
const { t } = useTranslation(["page-upgrades-index", "page-upgrades"])
2729

2830
const datapoints: CardListItem[] = [

src/components/BoxGrid.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Emoji from "./Emoji"
77
import OldHeading from "./OldHeading"
88
import Text from "./OldText"
99

10-
export interface IBoxItem {
10+
export interface BoxItem {
1111
emoji: string
1212
title: string
1313
description: string
1414
matomo: MatomoEventOptions
1515
}
1616

17-
export interface IProps {
18-
items: Array<IBoxItem>
17+
export type BoxGridProps = {
18+
items: Array<BoxItem>
1919
}
2020

2121
// Represent string as 32-bit integer
@@ -40,7 +40,7 @@ const colors = [
4040
"gridPurple",
4141
]
4242

43-
const BoxGrid: React.FC<IProps> = ({ items }) => {
43+
const BoxGrid = ({ items }: BoxGridProps) => {
4444
const [indexOpen, setOpenIndex] = useState(0)
4545

4646
return (

src/components/ButtonDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export interface List {
3333
items: Array<ListItem>
3434
}
3535

36-
export interface IProps extends ButtonProps {
36+
export type ButtonDropdownProps = ButtonProps & {
3737
list: List
3838
}
3939

40-
const ButtonDropdown: React.FC<IProps> = ({ list, ...rest }) => {
40+
const ButtonDropdown = ({ list, ...rest }: ButtonDropdownProps) => {
4141
const { t } = useTranslation("common")
4242
const handleClick = (
4343
e: MouseEvent<HTMLElement>,

src/components/CallToContribute.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ import React, { ReactNode } from "react"
22
import { FaGithub } from "react-icons/fa"
33
import { Flex, FlexProps, Icon, useToken } from "@chakra-ui/react"
44

5+
import { ChildOnlyProp } from "@/lib/types"
6+
57
import { ButtonLink } from "./Buttons"
68
import InlineLink from "./Link"
79
import OldHeading from "./OldHeading"
810
import Text from "./OldText"
911
import Translation from "./Translation"
1012

11-
export interface IProps {
13+
export type CallToContributeProps = {
1214
editPath: string
1315
}
1416

15-
export type ChildOnlyType = {
16-
children: ReactNode
17-
}
18-
1917
const ContentColumn = (props: {
2018
children: ReactNode
2119
hideBelow?: FlexProps["hideBelow"]
@@ -32,13 +30,13 @@ const ContentColumn = (props: {
3230
/>
3331
)
3432

35-
const DescriptionParagraph = ({ children }: ChildOnlyType) => (
33+
const DescriptionParagraph = ({ children }: ChildOnlyProp) => (
3634
<Text lineHeight="140%" color="text" fontFamily="monospace">
3735
{children}
3836
</Text>
3937
)
4038

41-
const CallToContribute: React.FC<IProps> = ({ editPath }) => {
39+
const CallToContribute = ({ editPath }: CallToContributeProps) => {
4240
/**
4341
* TODO: After completion of the UI migration,
4442
* Remove this and pass the token value directly

src/components/Callout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Image, type ImageProps } from "@/components/Image"
88
import OldHeading from "@/components/OldHeading"
99
import Text from "@/components/OldText"
1010

11-
export interface IProps extends FlexProps {
11+
export type CalloutProps = FlexProps & {
1212
children?: React.ReactNode
1313
image?: ImageProps["src"]
1414
emoji?: string
@@ -18,7 +18,7 @@ export interface IProps extends FlexProps {
1818
className?: string
1919
}
2020

21-
const Callout: React.FC<IProps> = ({
21+
const Callout = ({
2222
image,
2323
emoji,
2424
alt,
@@ -27,7 +27,7 @@ const Callout: React.FC<IProps> = ({
2727
children,
2828
className,
2929
...rest
30-
}) => {
30+
}: CalloutProps) => {
3131
const { t } = useTranslation("common")
3232

3333
return (

0 commit comments

Comments
 (0)