Skip to content

Commit

Permalink
build(frontend): Upgrade to React 19 (#622)
Browse files Browse the repository at this point in the history
* build(frontend): Upgrade to React 19

* fix TS errors in useInterval and usePrevious hooks
  • Loading branch information
eatyourgreens authored Dec 18, 2024
1 parent d496a5a commit 04cf330
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
8 changes: 4 additions & 4 deletions frontend-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"@reduxjs/toolkit": "^2.5.0",
"papaparse": "^5.4.1",
"plotly.js-basic-dist-min": "^2.35.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-dropzone": "^14.3.5",
"react-hook-form": "^7.54.1",
"react-player": "^2.16.0",
Expand Down Expand Up @@ -64,8 +64,8 @@
"@types/jest": "^29.5.14",
"@types/node": "^20.17.10",
"@types/papaparse": "^5.3.15",
"@types/react": "^18.3.17",
"@types/react-dom": "^18.3.5",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@types/react-plotly.js": "^2.6.3",
"@vitejs/plugin-react": "^4.3.4",
"cypress": "^12.17.4",
Expand Down
4 changes: 3 additions & 1 deletion frontend-v2/src/hooks/useInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ type IntervalProps = {
isDirty?: boolean;
};

const defaultCallback = () => null;

export default function useInterval({
callback,
delay,
isDirty = false,
}: IntervalProps) {
const savedCallback = useRef<() => void>();
const savedCallback = useRef<() => void>(defaultCallback);

useEffect(() => {
savedCallback.current = callback;
Expand Down
2 changes: 1 addition & 1 deletion frontend-v2/src/hooks/usePrevious.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef } from "react";

function usePrevious(value: any) {
const ref = useRef();
const ref = useRef(null);
useEffect(() => {
ref.current = value; //assign the value of ref to the argument
}, [value]); //this code will run when the value of 'value' changes
Expand Down
62 changes: 28 additions & 34 deletions frontend-v2/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3255,12 +3255,12 @@ __metadata:
languageName: node
linkType: hard

"@types/react-dom@npm:^18.3.5":
version: 18.3.5
resolution: "@types/react-dom@npm:18.3.5"
"@types/react-dom@npm:^19.0.2":
version: 19.0.2
resolution: "@types/react-dom@npm:19.0.2"
peerDependencies:
"@types/react": ^18.0.0
checksum: 10c0/b163d35a6b32a79f5782574a7aeb12a31a647e248792bf437e6d596e2676961c394c5e3c6e91d1ce44ae90441dbaf93158efb4f051c0d61e2612f1cb04ce4faa
"@types/react": ^19.0.0
checksum: 10c0/3d0c7b78dbe8df64ea769f30af990a5950173a8321c745fe11094d765423f7964c3519dca6e7cd36b4be6521c8efc690bdd3b79b327b229dd1e9d5a8bad677dd
languageName: node
linkType: hard

Expand Down Expand Up @@ -3293,13 +3293,12 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:^18.3.17":
version: 18.3.17
resolution: "@types/react@npm:18.3.17"
"@types/react@npm:^19.0.1":
version: 19.0.1
resolution: "@types/react@npm:19.0.1"
dependencies:
"@types/prop-types": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10c0/475191e9cd0ab5bef35cc1868295d6526cd78b25c1bb816f0747a1e92261688305f81c0e29aff52e6ea70397f133e34c399dc936cb5072f1acf465d9daacc0da
checksum: 10c0/25eb69114abb9a6d5fc4414ee584388275bbc9ac32976449cf58b95fe9880efe6b3f936c3842be9bed8c571546a9752e8d3e2095288381e9c809269f5f574f2e
languageName: node
linkType: hard

Expand Down Expand Up @@ -5697,8 +5696,8 @@ __metadata:
"@types/jest": "npm:^29.5.14"
"@types/node": "npm:^20.17.10"
"@types/papaparse": "npm:^5.3.15"
"@types/react": "npm:^18.3.17"
"@types/react-dom": "npm:^18.3.5"
"@types/react": "npm:^19.0.1"
"@types/react-dom": "npm:^19.0.2"
"@types/react-plotly.js": "npm:^2.6.3"
"@vitejs/plugin-react": "npm:^4.3.4"
cypress: "npm:^12.17.4"
Expand All @@ -5712,8 +5711,8 @@ __metadata:
papaparse: "npm:^5.4.1"
plotly.js-basic-dist-min: "npm:^2.35.3"
prettier: "npm:^3.4.2"
react: "npm:^18.3.1"
react-dom: "npm:^18.3.1"
react: "npm:^19.0.0"
react-dom: "npm:^19.0.0"
react-dropzone: "npm:^14.3.5"
react-hook-form: "npm:^7.54.1"
react-player: "npm:^2.16.0"
Expand Down Expand Up @@ -7002,7 +7001,7 @@ __metadata:
languageName: node
linkType: hard

"loose-envify@npm:^1.1.0, loose-envify@npm:^1.4.0":
"loose-envify@npm:^1.4.0":
version: 1.4.0
resolution: "loose-envify@npm:1.4.0"
dependencies:
Expand Down Expand Up @@ -7959,15 +7958,14 @@ __metadata:
languageName: node
linkType: hard

"react-dom@npm:^18.3.1":
version: 18.3.1
resolution: "react-dom@npm:18.3.1"
"react-dom@npm:^19.0.0":
version: 19.0.0
resolution: "react-dom@npm:19.0.0"
dependencies:
loose-envify: "npm:^1.1.0"
scheduler: "npm:^0.23.2"
scheduler: "npm:^0.25.0"
peerDependencies:
react: ^18.3.1
checksum: 10c0/a752496c1941f958f2e8ac56239172296fcddce1365ce45222d04a1947e0cc5547df3e8447f855a81d6d39f008d7c32eab43db3712077f09e3f67c4874973e85
react: ^19.0.0
checksum: 10c0/a36ce7ab507b237ae2759c984cdaad4af4096d8199fb65b3815c16825e5cfeb7293da790a3fc2184b52bfba7ba3ff31c058c01947aff6fd1a3701632aabaa6a9
languageName: node
linkType: hard

Expand Down Expand Up @@ -8108,12 +8106,10 @@ __metadata:
languageName: node
linkType: hard

"react@npm:^18.3.1":
version: 18.3.1
resolution: "react@npm:18.3.1"
dependencies:
loose-envify: "npm:^1.1.0"
checksum: 10c0/283e8c5efcf37802c9d1ce767f302dd569dd97a70d9bb8c7be79a789b9902451e0d16334b05d73299b20f048cbc3c7d288bbbde10b701fa194e2089c237dbea3
"react@npm:^19.0.0":
version: 19.0.0
resolution: "react@npm:19.0.0"
checksum: 10c0/9cad8f103e8e3a16d15cb18a0d8115d8bd9f9e1ce3420310aea381eb42aa0a4f812cf047bb5441349257a05fba8a291515691e3cb51267279b2d2c3253f38471
languageName: node
linkType: hard

Expand Down Expand Up @@ -8509,12 +8505,10 @@ __metadata:
languageName: node
linkType: hard

"scheduler@npm:^0.23.2":
version: 0.23.2
resolution: "scheduler@npm:0.23.2"
dependencies:
loose-envify: "npm:^1.1.0"
checksum: 10c0/26383305e249651d4c58e6705d5f8425f153211aef95f15161c151f7b8de885f24751b377e4a0b3dd42cce09aad3f87a61dab7636859c0d89b7daf1a1e2a5c78
"scheduler@npm:^0.25.0":
version: 0.25.0
resolution: "scheduler@npm:0.25.0"
checksum: 10c0/a4bb1da406b613ce72c1299db43759526058fdcc413999c3c3e0db8956df7633acf395cb20eb2303b6a65d658d66b6585d344460abaee8080b4aa931f10eaafe
languageName: node
linkType: hard

Expand Down

0 comments on commit 04cf330

Please sign in to comment.