Skip to content

Commit df25640

Browse files
feat: support React 19 with upgrading types (#1877)
## 📝 Changes - Updates React support to include React 19 **Consumers will need to install `react-is` with upgrade**
1 parent 04f4cc3 commit df25640

28 files changed

Lines changed: 246 additions & 225 deletions

.changeset/fancy-mangos-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@easypost/easy-ui": minor
3+
---
4+
5+
feat: support React 19

easy-ui-react/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,37 @@
3535
"@react-aria/utils": "^3.32.0",
3636
"@react-stately/toast": "^3.1.2",
3737
"@react-types/shared": "^3.32.1",
38-
"@types/react": "^18.3.1",
39-
"@types/react-dom": "^18.3.1",
4038
"lodash": "^4.17.21",
4139
"overlayscrollbars": "^2.3.0",
4240
"overlayscrollbars-react": "^0.5.6",
4341
"react-aria": "^3.45.0",
4442
"react-aria-components": "^1.14.0",
45-
"react-is": "^18.3.1",
4643
"react-stately": "^3.43.0",
4744
"react-syntax-highlighter": "^15.6.1",
4845
"react-transition-group": "^4.4.5",
4946
"use-clipboard-copy": "^0.2.0"
5047
},
5148
"peerDependencies": {
52-
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
53-
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
49+
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
50+
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
51+
"react-is": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
5452
},
5553
"devDependencies": {
5654
"@testing-library/dom": "^10.4.0",
5755
"@testing-library/jest-dom": "^6.6.3",
58-
"@testing-library/react": "^16.3.0",
56+
"@testing-library/react": "^16.3.2",
5957
"@testing-library/user-event": "^14.6.1",
6058
"@types/lodash": "^4.17.18",
61-
"@types/react-is": "^18.3.0",
59+
"@types/react": "^19.2.14",
60+
"@types/react-dom": "^19.2.3",
61+
"@types/react-is": "^19.0.0",
6262
"@types/react-syntax-highlighter": "^15.5.13",
6363
"@types/react-transition-group": "^4.4.12",
6464
"@vitejs/plugin-react": "^4.6.0",
6565
"glob": "^10.2.5",
66-
"react": "^18.3.1",
67-
"react-dom": "^18.3.1",
66+
"react": "^19.0.0",
67+
"react-dom": "^19.0.0",
68+
"react-is": "^19.0.0",
6869
"sass": "^1.89.2",
6970
"vite-plugin-react-remove-attributes": "^1.0.3",
7071
"vite-plugin-static-copy": "^3.1.2"

easy-ui-react/src/CodeBlock/CodeBlock.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, useMemo } from "react";
1+
import React, { ReactElement, ReactNode, useMemo } from "react";
22
import { CodeSnippet, CodeSnippetProps } from "../CodeSnippet";
33
import { SnippetLanguage } from "../CodeSnippet/SyntaxHighlighter";
44
import { HorizontalStack } from "../HorizontalStack";
@@ -120,7 +120,10 @@ export function CodeBlock(props: CodeBlockProps) {
120120
const { children, language, onLanguageChange } = props;
121121

122122
const snippets = useMemo(() => {
123-
return filterChildrenByDisplayName(children, "CodeBlock.Snippet");
123+
return filterChildrenByDisplayName(
124+
children,
125+
"CodeBlock.Snippet",
126+
) as ReactElement<CodeSnippetProps>[];
124127
}, [children]);
125128

126129
const headers = useMemo(() => {

easy-ui-react/src/CodeBlock/context.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ReactElement, createContext, useContext } from "react";
2+
import { CodeSnippetProps } from "../CodeSnippet";
23
import { SnippetLanguage } from "../CodeSnippet/SyntaxHighlighter";
34

45
export type CodeBlockContextType = {
56
languages: SnippetLanguage[];
6-
snippet: ReactElement;
7+
snippet: ReactElement<CodeSnippetProps>;
78
language: SnippetLanguage;
89
onLanguageChange: (language: SnippetLanguage) => void;
910
};

easy-ui-react/src/ColorPicker/ColorPicker.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ describe("<ColorPicker />", () => {
7474
expect(screen.getAllByLabelText("Color picker").length).toBeGreaterThan(0);
7575
await userTab(user);
7676
await userKeyboard(user, "{ArrowRight}{ArrowUp}{ArrowLeft}{ArrowDown}");
77-
expect(screen.getByText("hsla(0, 100%, 49.5%, 1)")).toBeInTheDocument();
77+
expect(screen.getByText("hsla(0, 98.02%, 50%, 1)")).toBeInTheDocument();
7878
});
7979
});

easy-ui-react/src/ColorPicker/ColorPickerInputField.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ describe("<ColorPickerInputField />", () => {
6161
await userTab(user);
6262
await userKeyboard(user, "{ArrowRight}{ArrowUp}{ArrowLeft}{ArrowDown}");
6363
expect(handleChange).toHaveBeenCalled();
64-
expect(screen.getByLabelText("Primary color")).toHaveValue("#FC0000");
64+
expect(screen.getByLabelText("Primary color")).toHaveValue("#FC0303");
6565
});
6666
});

easy-ui-react/src/DataGrid/Table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function Table<C extends Column, R extends RowType>(
4646
const innerContainerRef = useRef<HTMLDivElement | null>(null);
4747
const tableRef = useRef<HTMLTableElement | null>(null);
4848
const state = useTableState({
49-
...props,
49+
...(props as Parameters<typeof useTableState>[0]),
5050
selectionMode,
5151
selectionBehavior: "toggle",
5252
showSelectionCheckboxes: selectionMode !== "none",

easy-ui-react/src/Drawer/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export type DrawerContextType = {
66
dialogProps: DOMAttributes<FocusableElement>;
77
titleProps: DOMAttributes<FocusableElement>;
88
isHeaderStuck: boolean;
9-
bodyRef: RefObject<HTMLDivElement>;
10-
headerInterceptorRef: RefObject<HTMLDivElement>;
9+
bodyRef: RefObject<HTMLDivElement | null>;
10+
headerInterceptorRef: RefObject<HTMLDivElement | null>;
1111
};
1212

1313
type DrawerTriggerContextType = {

easy-ui-react/src/Drawer/useIntersectionDetection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { RefObject, useEffect, useState } from "react";
88
* @returns when element is intersecting
99
*/
1010
export function useIntersectionDetection(
11-
targetRef: RefObject<HTMLDivElement>,
12-
scrollRef: RefObject<HTMLDivElement>,
11+
targetRef: RefObject<HTMLDivElement | null>,
12+
scrollRef: RefObject<HTMLDivElement | null>,
1313
) {
1414
const [isStuck, setIsStuck] = useState(false);
1515

easy-ui-react/src/FormLayout/Section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ function findSectionTitleInChildren(children: ReactNode) {
6767
const firstTitleOrSectionType =
6868
firstTitleOrSection.type as NamedExoticComponent;
6969
return firstTitleOrSectionType.displayName === "FormLayout.Title"
70-
? firstTitleOrSection.props.children
70+
? (firstTitleOrSection.props as { children?: ReactNode }).children
7171
: null;
7272
}

0 commit comments

Comments
 (0)