Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade react@19 and next@15 #5147

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 8 additions & 8 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 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-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",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version was set automatically by codemod

"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 @@ -275,7 +275,7 @@
"@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-dom": "npm:[email protected]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feals like a strange change to me...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too, codemod did this

"@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 Down
Loading
Loading