Skip to content

Commit e64ad32

Browse files
authored
Upgrade React to v18 (#138)
* Upgrades react * Prevent Next.js router scroll on navigate (filter selections) * Upgrades * Remove Enzyme * Clean out unused dependencies * Add back prettier cli * Upgrade Remixicon
1 parent 7e7686a commit e64ad32

File tree

10 files changed

+2264
-3333
lines changed

10 files changed

+2264
-3333
lines changed

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,56 +39,38 @@
3939
"homepage": "https://github.com/mitodl/course-search-utils#readme",
4040
"dependencies": {
4141
"@mitodl/open-api-axios": "2024.9.16",
42-
"@remixicon/react": "4.0.1",
42+
"@remixicon/react": "^4.2.0",
4343
"axios": "^1.6.7",
44-
"fuse.js": "^7.0.0",
45-
"query-string": "^6.13.1"
44+
"fuse.js": "^7.0.0"
4645
},
4746
"devDependencies": {
47+
"@babel/preset-typescript": "^7.25.7",
4848
"@swc/core": "^1.5.7",
4949
"@swc/jest": "^0.2.36",
50-
"@testing-library/react": "12",
51-
"@testing-library/react-hooks": "^8.0.1",
50+
"@testing-library/react": "15",
5251
"@testing-library/user-event": "^14.5.2",
53-
"@types/enzyme": "^3.10.7",
5452
"@types/jest": "^29.0.1",
55-
"@types/lodash": "^4.14.162",
56-
"@types/lodash.uppercase": "^4.3.9",
5753
"@types/next": "^9.0.0",
58-
"@types/node": "^14.6",
59-
"@types/react": "16.14.62",
60-
"@types/react-dom": "16.9.24",
54+
"@types/react": "^18.2.0",
55+
"@types/react-dom": "^18.2.0",
6156
"@typescript-eslint/eslint-plugin": "^7.0.1",
62-
"@typescript-eslint/parser": "^7.0.1",
63-
"babel-eslint": "10.x",
64-
"enzyme": "^3.11.0",
65-
"enzyme-adapter-react-16": "^1.15.4",
66-
"eslint": "^8.56.0",
67-
"eslint-config-google": "0.x",
57+
"eslint": "8.57.1",
6858
"eslint-config-mitodl": "^2.0.0",
69-
"eslint-plugin-babel": "5.x",
70-
"eslint-plugin-flow-vars": "^0.5.0",
71-
"eslint-plugin-flowtype": "4.x",
72-
"eslint-plugin-mocha": "6.x",
73-
"eslint-plugin-react": "^7.32.2",
74-
"eslint-plugin-react-hooks": "^4.6.0",
75-
"history": "^5.3.0",
76-
"history-v4": "npm:history@^4.9",
59+
"eslint-plugin-react": "^7.37.1",
60+
"eslint-plugin-react-hooks": "^4.6.2",
7761
"jest": "^29.0.3",
78-
"jest-environment-jsdom": "^29.0.3",
79-
"jest-fetch-mock": "^3.0.3",
62+
"jest-environment-jsdom": "^29.7.0",
8063
"next": "^14.2.7",
81-
"prettier-eslint-cli": "^7.1.0",
82-
"react": "^16.13.1",
83-
"react-dom": "^16.13.1",
64+
"prettier-eslint-cli": "^8.0.1",
65+
"react": "^18.2.0",
66+
"react-dom": "^18.2.0",
8467
"react-router": "^6.22.2",
8568
"tiny-invariant": "^1.3.3",
8669
"ts-node": "^10.9.2",
8770
"typescript": "^5.3.3"
8871
},
8972
"peerDependencies": {
9073
"@types/history": "^4.9",
91-
"history": "^4.9 || ^5.0.0",
9274
"next": "^14.2.7",
9375
"react": "^16.13.1",
9476
"react-router": "^6.22.2"

src/facet_display/FilterableFacet.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ function FilterableFacet(props: Props) {
3939

4040
const [filterText, setFilterText] = useState("")
4141

42-
const handleFilterInput = useCallback(e => {
43-
e.preventDefault()
44-
const filterText = e.target.value || ""
45-
setFilterText(filterText)
46-
}, [])
42+
const handleFilterInput = useCallback(
43+
(e: React.ChangeEvent<HTMLInputElement>) => {
44+
e.preventDefault()
45+
const filterText = e.target.value || ""
46+
setFilterText(filterText)
47+
},
48+
[]
49+
)
4750

4851
const filteredResults = useMemo(() => {
4952
return filterText ?

src/hooks/useInfiniteSearch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { renderHook, act } from "@testing-library/react-hooks/dom"
1+
import { renderHook, act } from "@testing-library/react"
22
import useInfiniteSearch from "./useInfiniteSearch"
33

44
/**

src/hooks/useValidatedSearchParams.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable prefer-template */
22
import React from "react"
3-
import { renderHook, act } from "@testing-library/react-hooks/dom"
3+
import { renderHook, act } from "@testing-library/react"
44
import { useResourceSearchParams } from "./useValidatedSearchParams"
55
import type {
66
UseResourceSearchParamsProps,

src/next/useSearchParams.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ const useSearchParams = (): [URLSearchParams, SetSearchParams] => {
4848
searchParamsRef.current = newParams
4949

5050
if (hasNavigatedRef.current) {
51-
router.replace(`${pathname}?${newParams}`)
51+
router.replace(`${pathname}?${newParams}`, { scroll: false })
5252
} else {
53-
router.push(`${pathname}?${newParams}`)
53+
router.push(`${pathname}?${newParams}`, { scroll: false })
5454
}
5555

5656
hasNavigatedRef.current = true

src/react-router/useSearchParams.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { renderHook, act } from "@testing-library/react-hooks/dom"
1+
import { renderHook, act } from "@testing-library/react"
22
import React from "react"
33
import { MemoryRouter, useNavigate } from "react-router"
44
import type { MemoryRouterProps, NavigateFunction } from "react-router"

src/test_setup.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2-
// @ts-nocheck
3-
import Enzyme from "enzyme"
4-
import Adapter from "enzyme-adapter-react-16"
5-
6-
// eslint-disable-next-line @typescript-eslint/no-var-requires
7-
require("jest-fetch-mock").enableMocks()
8-
9-
Enzyme.configure({ adapter: new Adapter() })
10-
111
process.env = {
122
...process.env,
133
SEARCH_API_URL: "http://search-the-planet.example.com/search"

types/enzyme-adapter-react-16.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)