Skip to content

Commit 55a1b40

Browse files
CopilotmaximizeIT
andcommitted
Comprehensive fix for all open dependency PRs and React 18 compatibility
Co-authored-by: maximizeIT <8626039+maximizeIT@users.noreply.github.com>
1 parent 292c32a commit 55a1b40

5 files changed

Lines changed: 454 additions & 511 deletions

File tree

samples/weather-forecast/package.json

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,71 +17,69 @@
1717
"author": "",
1818
"license": "ISC",
1919
"dependencies": {
20-
"@staffbase/widget-sdk": "^3.14.13",
21-
"acorn": "^8.14.1",
22-
"axios": "1.9.0",
20+
"@staffbase/widget-sdk": "^3.15.0",
21+
"acorn": "^8.15.0",
22+
"axios": "1.12.0",
2323
"date-fns": "^2.23.0",
24-
"dayjs": "1.11.13",
24+
"dayjs": "1.11.18",
2525
"react": "^18.3.1",
2626
"react-cool-dimensions": "^3.0.1",
2727
"react-dom": "^18.3.1",
2828
"react-query": "3.39.3",
2929
"regenerator-runtime": "0.14.1"
3030
},
3131
"devDependencies": {
32-
"@babel/core": "^7.27.1",
32+
"@babel/core": "^7.28.4",
3333
"@babel/plugin-proposal-class-properties": "^7.18.6",
3434
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
3535
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
36-
"@babel/preset-env": "^7.27.1",
36+
"@babel/preset-env": "^7.28.3",
3737
"@babel/preset-react": "^7.27.1",
3838
"@babel/preset-typescript": "^7.27.1",
3939
"@emotion/react": "^11.14.0",
40-
"@emotion/styled": "^11.14.0",
40+
"@emotion/styled": "^11.14.1",
4141
"@mui/icons-material": "^6.3.0",
4242
"@mui/material": "^6.3.0",
4343
"@mui/system": "^6.1.4",
44-
"@rjsf/core": "5.24.10",
45-
"@rjsf/mui": "5.24.10",
46-
"@rjsf/utils": "5.24.10",
47-
"@rjsf/validator-ajv8": "5.24.10",
44+
"@rjsf/core": "5.24.13",
45+
"@rjsf/mui": "5.24.13",
46+
"@rjsf/utils": "5.24.13",
47+
"@rjsf/validator-ajv8": "5.24.13",
4848
"@svgr/webpack": "8.1.0",
49-
"@testing-library/dom": "^10.4.0",
50-
"@testing-library/jest-dom": "^6.6.3",
49+
"@testing-library/dom": "^10.4.1",
50+
"@testing-library/jest-dom": "^6.8.0",
5151
"@testing-library/react": "^16.3.0",
52-
"@testing-library/react-hooks": "7.0.2",
5352
"@types/copy-webpack-plugin": "^10.1.3",
5453
"@types/jest": "^29.5.14",
5554
"@types/json-schema": "^7.0.15",
56-
"@types/node": "16.11.9",
55+
"@types/node": "24.3.0",
5756
"@types/react": "^18.3.12",
5857
"@types/react-dom": "^18.3.1",
59-
"@types/testing-library__jest-dom": "^5.14.9",
6058
"@types/webpack": "5.28.5",
6159
"@types/webpack-dev-server": "4.7.2",
6260
"@typescript-eslint/eslint-plugin": "5.62.0",
63-
"@typescript-eslint/parser": "5.4.0",
61+
"@typescript-eslint/parser": "5.62.0",
6462
"@ungap/custom-elements": "1.3.0",
6563
"babel-eslint": "10.1.0",
6664
"babel-loader": "^9.2.1",
6765
"copy-webpack-plugin": "^12.0.2",
68-
"core-js": "3.42.0",
66+
"core-js": "3.45.1",
6967
"eslint": "8.3.0",
70-
"eslint-config-prettier": "8.3.0",
68+
"eslint-config-prettier": "10.1.8",
7169
"file-loader": "^6.2.0",
7270
"jest": "27.1.0",
7371
"jest-json-schema": "^6.1.0",
74-
"js-base64": "3.7.7",
72+
"js-base64": "3.7.8",
7573
"minimal-polyfills": "2.2.3",
76-
"prettier": "3.5.3",
74+
"prettier": "3.6.2",
7775
"react-svg-loader": "^3.0.3",
78-
"ts-loader": "^9.5.2",
76+
"ts-loader": "^9.5.4",
7977
"ts-node": "10.9.2",
8078
"typescript": "4.5.2",
8179
"url-loader": "^4.1.1",
82-
"webpack": "^5.99.7",
83-
"webpack-cli": "^5.1.4",
84-
"webpack-dev-server": "^5.2.1",
80+
"webpack": "^5.101.3",
81+
"webpack-cli": "^6.0.1",
82+
"webpack-dev-server": "^5.2.2",
8583
"webpack-merge": "^6.0.1"
8684
},
8785
"resolutions": {

samples/weather-forecast/src/api/useCity.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import axios from "axios";
1515

1616
import React, { FunctionComponent } from "react";
1717
import { QueryClient, QueryClientProvider, setLogger } from "react-query";
18-
import { renderHook } from "@testing-library/react-hooks";
18+
import { renderHook, waitFor } from "@testing-library/react";
1919

2020
import useCity from "./useCity";
2121
import { city } from "./mockData";
@@ -46,13 +46,13 @@ describe("useCity", () => {
4646

4747
it("should return the coordinatse", async () => {
4848
mockAxios.mockResolvedValueOnce({ data: city });
49-
const { result, waitFor } = renderHook(
49+
const { result } = renderHook(
5050
() => useCity({ key: "foo", location: "Berlin", lang: "de" }),
5151
{ wrapper }
5252
);
5353

5454
await waitFor(() => {
55-
return result.current.isSuccess;
55+
expect(result.current.isSuccess).toBe(true);
5656
});
5757

5858
expect(mockAxios).toHaveBeenCalledWith(endpoint, {

samples/weather-forecast/src/api/useWeather.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import axios from "axios";
1515

1616
import React, { FunctionComponent } from "react";
1717
import { QueryClient, QueryClientProvider, setLogger } from "react-query";
18-
import { renderHook } from "@testing-library/react-hooks";
18+
import { renderHook, waitFor } from "@testing-library/react";
1919

2020
import useWeather from "./useWeather";
2121
import { weather } from "./mockData";
@@ -45,13 +45,13 @@ describe("useWeather", () => {
4545

4646
it("should return weather data", async () => {
4747
mockAxios.mockResolvedValueOnce({ data: weather });
48-
const { result, waitFor } = renderHook(
48+
const { result } = renderHook(
4949
() => useWeather({ key: "foo", lat: 44, lon: 42 }),
5050
{ wrapper }
5151
);
5252

5353
await waitFor(() => {
54-
return result.current.isSuccess;
54+
expect(result.current.isSuccess).toBe(true);
5555
});
5656

5757
expect(mockAxios).toHaveBeenCalledWith(endpoint, {
@@ -78,13 +78,13 @@ describe("useWeather", () => {
7878

7979
it("should return an error, when the request fails", async () => {
8080
mockAxios.mockRejectedValue(new Error("XMLHTTPError"));
81-
const { result, waitFor } = renderHook(
81+
const { result } = renderHook(
8282
() => useWeather({ key: "foo", lat: 44, lon: 42 }),
8383
{ wrapper }
8484
);
8585

8686
await waitFor(() => {
87-
return result.current.isError;
87+
expect(result.current.isError).toBe(true);
8888
});
8989

9090
expect(result.current.error).toEqual(new Error("XMLHTTPError"));
@@ -94,13 +94,13 @@ describe("useWeather", () => {
9494
it("should return an error, when the data processing goes wrong", async () => {
9595
const { daily, ...rest } = weather; // eslint-disable-line @typescript-eslint/no-unused-vars
9696
mockAxios.mockResolvedValueOnce({ data: rest });
97-
const { result, waitFor } = renderHook(
97+
const { result } = renderHook(
9898
() => useWeather({ key: "foo", lat: 44, lon: 42 }),
9999
{ wrapper }
100100
);
101101

102102
await waitFor(() => {
103-
return result.current.isError;
103+
expect(result.current.isError).toBe(true);
104104
});
105105

106106
expect(result.current.error).toEqual(

samples/weather-forecast/src/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
import React from "react";
15-
import { createRoot } from "react-dom/client";
15+
import { createRoot, Root } from "react-dom/client";
1616

1717
import {
1818
BlockFactory,
@@ -45,6 +45,8 @@ const factory: BlockFactory = (BaseBlockClass, _widgetApi) => {
4545
extends BaseBlockClass
4646
implements BaseBlock
4747
{
48+
private root: Root | null = null;
49+
4850
public constructor() {
4951
super();
5052
}
@@ -58,7 +60,10 @@ const factory: BlockFactory = (BaseBlockClass, _widgetApi) => {
5860
}
5961

6062
public renderBlock(container: HTMLElement): void {
61-
createRoot(container).render(
63+
if (!this.root) {
64+
this.root = createRoot(container);
65+
}
66+
this.root.render(
6267
<WeatherForecast {...this.props} />
6368
);
6469
}

0 commit comments

Comments
 (0)