Skip to content

Commit 6512960

Browse files
lynnshaoyuzzmp
andauthored
chore: upgrade to react 18 (#3992)
* chore: upgrade to react 18 * fix: update tests * fix: fix lint issues and remove unnecessary react hooks testing library * fix: add types for stricter typescript checks * fix: fix additional typescript check issues * fix: revert to prev commmit * rebase * rebase * fix: fix lint issues and remove unnecessary react hooks testing library * fix: add types for stricter typescript checks * fix: fix additional typescript check issues * rebase * fix: rebase * fix * eslint fix * fix: package.json changes * fix: package.json changes * fix yarn lock * fix version package.json * fix: downgrade react-router-dom to original * fix: undo modification of .github/workflows/release.yaml * fix: revert cypress testing version update * rebase * rebase * fix: fix lint issues and remove unnecessary react hooks testing library * fix: add types for stricter typescript checks * fix: fix additional typescript check issues * rebase * chore: upgrade to react 18 * fix: update tests * fix: fix lint issues and remove unnecessary react hooks testing library * fix: add types for stricter typescript checks * fix: fix additional typescript check issues * fix * eslint fix * fix: package.json changes * fix: package.json changes * fix yarn lock * fix version package.json * fix: downgrade react-router-dom to original * fix: undo modification of .github/workflows/release.yaml * fix: revert cypress testing version update * fix * fix: error boundary change * yarn.lock change * fix: cypress tests finally passing due to zzmp redux multicall fix HOORAY * undo service worker changes * build: dedup lockfile * yarn.lock + lint * update snapshot tests * checkpoint * yarn.lock * fix: fix type errors during build * fixes * fix yarn.lock * dedup yarn * fix: import react components explicitly instead of all of react * dedup * yarn.lock * yarn.lock * dedup * yarn * dedup * dedupe use-sync-external-store * fix build issues * dedup use-sync-external-store Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
1 parent 4e0c9b3 commit 6512960

File tree

20 files changed

+163
-164
lines changed

20 files changed

+163
-164
lines changed

package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@
6161
"@graphql-codegen/typescript-operations": "^1.18.2",
6262
"@graphql-codegen/typescript-rtk-query": "^1.1.1",
6363
"@lingui/cli": "^3.9.0",
64-
"@testing-library/jest-dom": "^5.14.1",
65-
"@testing-library/react": "^12.0.0",
66-
"@testing-library/react-hooks": "^7.0.2",
64+
"@testing-library/jest-dom": "^5.16.4",
65+
"@testing-library/react": "^13.1",
6766
"@typechain/ethers-v5": "^7.0.0",
6867
"@types/array.prototype.flat": "^1.2.1",
6968
"@types/array.prototype.flatmap": "^1.2.2",
@@ -76,10 +75,10 @@
7675
"@types/multicodec": "^1.0.0",
7776
"@types/node": "^13.13.5",
7877
"@types/qs": "^6.9.2",
79-
"@types/react": "^17.0.2",
80-
"@types/react-dom": "^17.0.1",
81-
"@types/react-redux": "^7.1.16",
82-
"@types/react-router-dom": "^5.0.0",
78+
"@types/react": "^18.0.15",
79+
"@types/react-dom": "^18.0.6",
80+
"@types/react-redux": "^7.1.24",
81+
"@types/react-router-dom": "^5.3.3",
8382
"@types/react-virtualized-auto-sizer": "^1.0.0",
8483
"@types/react-window": "^1.8.2",
8584
"@types/rebass": "^4.0.7",
@@ -110,9 +109,9 @@
110109
"@coinbase/wallet-sdk": "^3.3.0",
111110
"@fontsource/ibm-plex-mono": "^4.5.1",
112111
"@fontsource/inter": "^4.5.1",
113-
"@lingui/core": "^3.9.0",
114-
"@lingui/macro": "^3.9.0",
115-
"@lingui/react": "^3.9.0",
112+
"@lingui/core": "^3.14.0",
113+
"@lingui/macro": "^3.14.0",
114+
"@lingui/react": "^3.14.0",
116115
"@metamask/jazzicon": "^2.0.0",
117116
"@popperjs/core": "^2.4.4",
118117
"@reach/dialog": "^0.10.3",
@@ -169,15 +168,15 @@
169168
"popper-max-size-modifier": "^0.2.0",
170169
"prettier": "^2.2.1",
171170
"qs": "^6.9.4",
172-
"react": "^17.0.1",
171+
"react": "^18.2.0",
173172
"react-confetti": "^6.0.0",
174-
"react-dom": "^17.0.1",
173+
"react-dom": "^18.2.0",
175174
"react-feather": "^2.0.8",
176175
"react-ga4": "^1.4.1",
177176
"react-is": "^17.0.2",
178177
"react-markdown": "^4.3.1",
179178
"react-popper": "^2.2.3",
180-
"react-redux": "^7.2.2",
179+
"react-redux": "^8.0.2",
181180
"react-router-dom": "^5.0.0",
182181
"react-spring": "^8.0.27",
183182
"react-use-gesture": "^6.0.14",

src/components/AccountDetails/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Trans } from '@lingui/macro'
22
import { useWeb3React } from '@web3-react/core'
33
import CopyHelper from 'components/AccountDetails/Copy'
44
import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsMetaMask } from 'connection/utils'
5-
import { useCallback, useContext } from 'react'
5+
import { Context, useCallback, useContext } from 'react'
66
import { ExternalLink as LinkIcon } from 'react-feather'
77
import { useAppDispatch } from 'state/hooks'
88
import { updateSelectedWallet } from 'state/user/reducer'
9+
import { DefaultTheme } from 'styled-components/macro'
910
import styled, { ThemeContext } from 'styled-components/macro'
1011
import { isMobile } from 'utils/userAgent'
1112

@@ -205,7 +206,7 @@ export default function AccountDetails({
205206
const { chainId, account, connector } = useWeb3React()
206207
const connectionType = getConnection(connector).type
207208

208-
const theme = useContext(ThemeContext)
209+
const theme = useContext(ThemeContext as Context<DefaultTheme>)
209210
const dispatch = useAppDispatch()
210211

211212
const isMetaMask = getIsMetaMask()

src/components/AddressInputPanel/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Trans } from '@lingui/macro'
22
// eslint-disable-next-line no-restricted-imports
33
import { t } from '@lingui/macro'
44
import { useWeb3React } from '@web3-react/core'
5-
import { ReactNode, useCallback, useContext } from 'react'
6-
import styled, { ThemeContext } from 'styled-components/macro'
5+
import { ChangeEvent, Context, ReactNode, useCallback, useContext } from 'react'
6+
import styled, { DefaultTheme, ThemeContext } from 'styled-components/macro'
77

88
import useENS from '../../hooks/useENS'
99
import { ExternalLink, ThemedText } from '../../theme'
@@ -87,12 +87,12 @@ export default function AddressInputPanel({
8787
onChange: (value: string) => void
8888
}) {
8989
const { chainId } = useWeb3React()
90-
const theme = useContext(ThemeContext)
90+
const theme = useContext(ThemeContext as Context<DefaultTheme>)
9191

9292
const { address, loading, name } = useENS(value)
9393

9494
const handleInput = useCallback(
95-
(event) => {
95+
(event: ChangeEvent<HTMLInputElement>) => {
9696
const input = event.target.value
9797
const withoutSpaces = input.replace(/\s+/g, '')
9898
onChange(withoutSpaces)

src/components/ErrorBoundary/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Trans } from '@lingui/macro'
22
import { sendEvent } from 'components/analytics'
3-
import React, { ErrorInfo } from 'react'
3+
import React, { ErrorInfo, PropsWithChildren } from 'react'
44
import styled from 'styled-components/macro'
55

66
import store, { AppState } from '../../state'
@@ -56,8 +56,8 @@ async function updateServiceWorker(): Promise<ServiceWorkerRegistration> {
5656
return ready.update() as unknown as Promise<ServiceWorkerRegistration>
5757
}
5858

59-
export default class ErrorBoundary extends React.Component<unknown, ErrorBoundaryState> {
60-
constructor(props: unknown) {
59+
export default class ErrorBoundary extends React.Component<PropsWithChildren<unknown>, ErrorBoundaryState> {
60+
constructor(props: PropsWithChildren<unknown>) {
6161
super(props)
6262
this.state = { error: null }
6363
}

src/components/LiquidityChartRangeInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default function LiquidityChartRangeInput({
103103
})
104104

105105
const onBrushDomainChangeEnded = useCallback(
106-
(domain, mode) => {
106+
(domain: [number, number], mode: string | undefined) => {
107107
let leftRangeValue = Number(domain[0])
108108
const rightRangeValue = Number(domain[1])
109109

src/components/Menu/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { L2_CHAIN_IDS } from 'constants/chains'
66
import { LOCALE_LABEL, SUPPORTED_LOCALES, SupportedLocale } from 'constants/locales'
77
import { useActiveLocale } from 'hooks/useActiveLocale'
88
import { useLocationLinkProps } from 'hooks/useLocationLinkProps'
9-
import React, { useEffect, useRef, useState } from 'react'
9+
import { FunctionComponent, PropsWithChildren, useEffect, useRef, useState } from 'react'
1010
import {
1111
BookOpen,
1212
Check,
@@ -311,7 +311,7 @@ export default function Menu() {
311311

312312
interface NewMenuProps {
313313
flyoutAlignment?: FlyoutAlignment
314-
ToggleUI?: React.FunctionComponent
314+
ToggleUI?: FunctionComponent<PropsWithChildren<unknown>>
315315
menuItems: {
316316
content: any
317317
link: string

src/components/RoutingDiagram/RoutingDiagram.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Protocol } from '@uniswap/router-sdk'
22
import { Currency, Percent } from '@uniswap/sdk-core'
33
import { FeeAmount } from '@uniswap/v3-sdk'
4+
import { RoutingDiagramEntry } from 'components/swap/SwapRoute'
45
import { DAI, USDC_MAINNET, WBTC } from 'constants/tokens'
56
import { render } from 'test-utils'
67

7-
import RoutingDiagram, { RoutingDiagramEntry } from './RoutingDiagram'
8+
import RoutingDiagram from './RoutingDiagram'
89

910
const percent = (strings: TemplateStringsArray) => new Percent(parseInt(strings[0]), 100)
1011

src/components/SearchModal/CurrencyList/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ function BreakLineComponent({ style }: { style: CSSProperties }) {
197197
)
198198
}
199199

200+
interface TokenRowProps {
201+
data: Array<Currency | BreakLine>
202+
index: number
203+
style: CSSProperties
204+
}
205+
200206
const formatAnalyticsEventProperties = (
201207
token: Token,
202208
index: number,
@@ -253,7 +259,7 @@ export default function CurrencyList({
253259
}, [currencies, otherListTokens])
254260

255261
const Row = useCallback(
256-
function TokenRow({ data, index, style }) {
262+
function TokenRow({ data, index, style }: TokenRowProps) {
257263
const row: Currency | BreakLine = data[index]
258264

259265
if (isBreakLine(row)) {

src/components/SearchModal/CurrencySearch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import useToggle from 'hooks/useToggle'
1212
import useNativeCurrency from 'lib/hooks/useNativeCurrency'
1313
import { getTokenFilter } from 'lib/hooks/useTokenList/filtering'
1414
import { tokenComparator, useSortTokensByQuery } from 'lib/hooks/useTokenList/sorting'
15-
import { KeyboardEvent, RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react'
15+
import { ChangeEvent, KeyboardEvent, RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react'
1616
import { Edit } from 'react-feather'
1717
import AutoSizer from 'react-virtualized-auto-sizer'
1818
import { FixedSizeList } from 'react-window'
@@ -146,7 +146,7 @@ export function CurrencySearch({
146146

147147
// manage focus on modal show
148148
const inputRef = useRef<HTMLInputElement>()
149-
const handleInput = useCallback((event) => {
149+
const handleInput = useCallback((event: ChangeEvent<HTMLInputElement>) => {
150150
const input = event.target.value
151151
const checksummedInput = isAddress(input)
152152
setSearchQuery(checksummedInput || input)

src/components/SearchModal/ManageLists.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { UNSUPPORTED_LIST_URLS } from 'constants/lists'
88
import { useListColor } from 'hooks/useColor'
99
import parseENSAddress from 'lib/utils/parseENSAddress'
1010
import uriToHttp from 'lib/utils/uriToHttp'
11-
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
11+
import { ChangeEvent, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
1212
import { CheckCircle, Settings } from 'react-feather'
1313
import { usePopper } from 'react-popper'
1414
import { useAppDispatch, useAppSelector } from 'state/hooks'
@@ -266,7 +266,7 @@ export function ManageLists({
266266
// sort by active but only if not visible
267267
const activeListUrls = useActiveListUrls()
268268

269-
const handleInput = useCallback((e) => {
269+
const handleInput = useCallback((e: ChangeEvent<HTMLInputElement>) => {
270270
setListUrlInput(e.target.value)
271271
}, [])
272272

0 commit comments

Comments
 (0)