Skip to content

Commit

Permalink
feat: upgrade react@19 and next@15 (#5147)
Browse files Browse the repository at this point in the history
* feat: upgrade react@19 and next@15

* chore: upgrade fortawesome

* chore: upgrade react deps
  • Loading branch information
shoom3301 authored Dec 4, 2024
1 parent 104831c commit a00b1b9
Show file tree
Hide file tree
Showing 12 changed files with 674 additions and 293 deletions.
2 changes: 1 addition & 1 deletion apps/cow-fi/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { COW, NATIVE_CURRENCIES } from '@cowprotocol/common-const'
import { useWalletInfo } from '@cowprotocol/wallet'
import { BigNumber } from '@ethersproject/bignumber'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'

import { useTransactionAdder } from 'legacy/state/enhancedTransactions/hooks'
import { Order } from 'legacy/state/orders/actions'
Expand Down
8 changes: 3 additions & 5 deletions apps/cowswap-frontend/src/common/hooks/useSafeMemo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo, useState } from 'react'
import { SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'

import { useSafeMemo } from './useSafeMemo'

Expand Down Expand Up @@ -38,7 +38,7 @@ describe('useSafeMemo() to avoid redundant actuation of hooks', () => {
let memoCalls = 0
let updatesCount = 3

const { result } = renderHook(() => {
renderHook(() => {
const [state, setState] = useState(createStaticObject())

const memoized = useSafeMemo(() => {
Expand All @@ -55,14 +55,13 @@ describe('useSafeMemo() to avoid redundant actuation of hooks', () => {
})

expect(memoCalls).toBe(1)
expect(result.all.length).toBe(4)
})

it('Should execute memo on each setState() call using regular useMemo()', () => {
let memoCalls = 0
let updatesCount = 3

const { result } = renderHook(() => {
renderHook(() => {
const [state, setState] = useState(createStaticObject())
const { inputCurrency, outputCurrency, inputAmount, outputAmount, address } = state

Expand All @@ -80,6 +79,5 @@ describe('useSafeMemo() to avoid redundant actuation of hooks', () => {
})

expect(memoCalls).toBe(4)
expect(result.all.length).toBe(4)
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useIsBundlingSupported } from '@cowprotocol/wallet'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'

import { PriceImpact } from 'legacy/hooks/usePriceImpact'

Expand Down Expand Up @@ -99,7 +99,7 @@ describe('useHandleOrderPlacement', () => {

updateLimitOrdersState({ recipient })
},
{ wrapper: WithModalProvider }
{ wrapper: WithModalProvider },
)

// Assert
Expand All @@ -111,7 +111,7 @@ describe('useHandleOrderPlacement', () => {
// Act
const { result } = renderHook(
() => useHandleOrderPlacement(tradeContextMock, priceImpactMock, defaultLimitOrdersSettings, tradeConfirmActions),
{ wrapper: WithModalProvider }
{ wrapper: WithModalProvider },
)
await result.current()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react'

import { WETH_SEPOLIA } from '@cowprotocol/common-const'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'

import { useTradeApproveCallback } from 'common/containers/TradeApprove'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ReactNode } from 'react'
import { WETH_GNOSIS_CHAIN } from '@cowprotocol/common-const'
import { CurrencyAmount, Fraction } from '@uniswap/sdk-core'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'
import { JotaiTestProvider } from 'test-utils'

import { useUsdAmount } from './useUsdAmount'
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('useUsdAmount', () => {
() => {
return useUsdAmount(ONE_WETH)
},
{ wrapper: TestComponent }
{ wrapper: TestComponent },
)

expect(result.current.value?.toExact()).toBe(WETH_RAW_PRICE_STATE?.price?.toFixed(0))
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/src/test/hooks/useDecomposedPath.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

import { renderHook } from '@testing-library/react-hooks'
import { renderHook } from '@testing-library/react'
import { MemoryRouter } from 'react-router'
import { useDecomposedPath, usePathPrefix, usePathSuffix } from 'state/network'

Expand Down
9 changes: 6 additions & 3 deletions apps/explorer/src/test/hooks/useSafeState.hooks.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState } from 'react'

import { act } from '@testing-library/react'
import useSafeState from 'hooks/useSafeState'
import ReactDOM from 'react-dom'
import { act } from 'react-dom/test-utils'

import { createRoot } from 'react-dom/client'

interface TestComponentI {
safeUpdate?: boolean
Expand Down Expand Up @@ -51,7 +51,10 @@ afterEach(() => {
describe('Tests button click state change', () => {
it('Renders and useSafeState works to change state', async () => {
act(() => {
ReactDOM.render(<TestComponent safeUpdate />, container)
if (!container) return

const root = createRoot(container)
root.render(<TestComponent safeUpdate />)
})

const button = (container as HTMLDivElement).querySelector('#buttonTest')
Expand Down
4 changes: 2 additions & 2 deletions apps/explorer/src/test/hooks/useSearchSubmit.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook, act } from '@testing-library/react-hooks'
import { renderHook, act } from '@testing-library/react'
import { LocationDescriptorObject } from 'history'
import { useSearchSubmit } from 'hooks/useSearchSubmit'
import { MemoryRouter, useLocation } from 'react-router-dom'
Expand All @@ -22,7 +22,7 @@ function runHook(query: string) {
},
{
wrapper: ({ children }) => wrapperMemoryRouter({ children }),
}
},
)

act(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/src/test/hooks/useTable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act, renderHook } from '@testing-library/react-hooks'
import { act, renderHook } from '@testing-library/react'

import { useTable } from '../../explorer/components/OrdersTableWidget/useTable'

Expand Down
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
},
"resolutions": {
"@safe-global/safe-apps-provider/**/@safe-global/safe-apps-sdk": "^9.1.0",
"@web3-react/gnosis-safe/**/@safe-global/safe-apps-sdk": "^9.1.0"
"@web3-react/gnosis-safe/**/@safe-global/safe-apps-sdk": "^9.1.0",
"@types/react-dom": "npm:[email protected]"
},
"dependencies": {
"@1inch/permit-signed-approvals-utils": "^1.4.10",
Expand All @@ -81,10 +82,10 @@
"@ethersproject/experimental": "^5.7.0",
"@fontsource/ibm-plex-mono": "^4.5.1",
"@fontsource/inter": "^4.5.1",
"@fortawesome/fontawesome-svg-core": "^6.1.2",
"@fortawesome/free-regular-svg-icons": "^6.1.2",
"@fortawesome/free-solid-svg-icons": "^6.1.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
"@fortawesome/free-regular-svg-icons": "^6.7.1",
"@fortawesome/free-solid-svg-icons": "^6.7.1",
"@fortawesome/react-fontawesome": "^0.2.2",
"@gnosis.pm/dex-js": "^0.10.0",
"@lingui/cli": "^4.10.0",
"@lingui/core": "^4.10.0",
Expand Down Expand Up @@ -182,27 +183,27 @@
"mui-color-input": "^2.0.1",
"multicodec": "^3.0.1",
"multihashes": "^4.0.2",
"next": "14.0.4",
"next": "15.0.3",
"next-sitemap": "^4.2.3",
"node-cache": "^5.1.0",
"polished": "^4.0.5",
"polyfill-object.fromentries": "^1.0.1",
"popper-max-size-modifier": "^0.2.0",
"qs": "^6.12.1",
"react": "18.2.0",
"react": "19.0.0-rc-66855b96-20241106",
"react-appzi": "^1.0.4",
"react-confetti": "^6.1.0",
"react-copy-to-clipboard": "^5.0.2",
"react-cytoscapejs": "^1.2.1",
"react-copy-to-clipboard": "^5.1.0",
"react-cytoscapejs": "^2.0.0",
"react-device-detect": "^1.6.2",
"react-dom": "18.2.0",
"react-dom": "19.0.0-rc-66855b96-20241106",
"react-feather": "^2.0.10",
"react-ga4": "^1.4.1",
"react-helmet": "^6.1.0",
"react-icons": "^5.2.1",
"react-inlinesvg": "^3.0.1",
"react-intersection-observer": "^9.10.1",
"react-is": "18.2.0",
"react-is": "19.0.0-rc-66855b96-20241106",
"react-markdown": "^9.0.0",
"react-popper": "^2.2.3",
"react-redux": "^8.0.2",
Expand Down Expand Up @@ -262,7 +263,6 @@
"@swc/core": "~1.3.85",
"@swc/plugin-styled-components": "^1.5.67",
"@testing-library/react": "14.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@typechain/ethers-v5": "^10.2.0",
"@types/clone-deep": "^4.0.1",
"@types/cytoscape": "^3.19.4",
Expand All @@ -274,8 +274,8 @@
"@types/ms.macro": "^2.0.0",
"@types/node": "18.16.9",
"@types/react-copy-to-clipboard": "^4.3.0",
"@types/react-cytoscapejs": "^1.2.2",
"@types/react-dom": "18.2.14",
"@types/react-cytoscapejs": "^1.2.5",
"@types/react-dom": "npm:[email protected]",
"@types/react-helmet": "^6.1.6",
"@types/react-is": "18.2.2",
"@types/react-router-hash-link": "^2.4.5",
Expand All @@ -300,7 +300,7 @@
"babel-plugin-transform-import-meta": "^2.2.0",
"cypress": "^12.16.0",
"eslint": "~9.9.1",
"eslint-config-next": "14.2.7",
"eslint-config-next": "15.0.3",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "^3.0.2",
"eslint-plugin-import": "2.30.0",
Expand All @@ -324,7 +324,6 @@
"prettier": "^3.3.3",
"react-cosmos": "^6.1.1",
"react-cosmos-plugin-vite": "^6.1.1",
"react-microsoft-clarity": "^1.2.0",
"rollup-plugin-visualizer": "^5.9.2",
"ts-jest": "^29.1.1",
"ts-mockito": "^2.6.1",
Expand Down
Loading

0 comments on commit a00b1b9

Please sign in to comment.