diff --git a/.changeset/unlucky-readers-nail.md b/.changeset/unlucky-readers-nail.md new file mode 100644 index 0000000000..d84e6d6b1c --- /dev/null +++ b/.changeset/unlucky-readers-nail.md @@ -0,0 +1,6 @@ +--- +"mobx-react-lite": minor +"mobx-react": minor +--- + +* Added React 19 support, fixes #3986 diff --git a/package.json b/package.json index 5f886c3f51..94123f577b 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,7 @@ "@changesets/cli": "^2.11.0", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "^16.0.1", - "@testing-library/react-hooks": "7.0.2", + "@testing-library/react": "^16.1.0", "@types/jest": "^26.0.15", "@types/node": "18", "@types/prop-types": "^15.5.2", @@ -62,8 +61,8 @@ "prettier": "^2.8.4", "pretty-quick": "3.1.0", "prop-types": "15.6.2", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", "react-test-renderer": "^18.0.0", "serializr": "^2.0.3", "tape": "^5.0.1", diff --git a/packages/mobx-react-lite/__tests__/observer.test.tsx b/packages/mobx-react-lite/__tests__/observer.test.tsx index 607e5d21df..f4f0a92b30 100644 --- a/packages/mobx-react-lite/__tests__/observer.test.tsx +++ b/packages/mobx-react-lite/__tests__/observer.test.tsx @@ -49,7 +49,7 @@ function runTestSuite(mode: "observer" | "useObserver") { list: 0 } - const TodoItem = obsComponent(({ todo }: { todo: typeof store.todos[0] }) => { + const TodoItem = obsComponent(({ todo }: { todo: (typeof store.todos)[0] }) => { renderings.item++ return
(
;(observerComponent as React.FunctionComponent).contextTypes = (
baseComponent as any
).contextTypes
+
+ if (process.env.NODE_ENV !== "production" && warnLegacyContextTypes) {
+ warnLegacyContextTypes = false
+ console.warn(
+ `[mobx-react-lite] Support for Legacy Context in function components will be removed in the next major release.`
+ )
+ }
}
if (useForwardRef) {
diff --git a/packages/mobx-react/__tests__/hooks.test.tsx b/packages/mobx-react/__tests__/hooks.test.tsx
index bc0a94cf87..a56ec15d53 100644
--- a/packages/mobx-react/__tests__/hooks.test.tsx
+++ b/packages/mobx-react/__tests__/hooks.test.tsx
@@ -49,7 +49,7 @@ test("computed properties react to props when using hooks", async () => {
act(() => {
jest.runAllTimers()
})
- expect(seen).toEqual(["parent", 0, "parent", 2])
+ expect(seen).toEqual(["parent", 0, "parent", 2, 2])
expect(container).toHaveTextContent("2")
expect(consoleWarnMock).toMatchSnapshot()
})
diff --git a/packages/mobx-react/__tests__/inject.test.tsx b/packages/mobx-react/__tests__/inject.test.tsx
index c2fdeaf85b..6f97ac25e2 100644
--- a/packages/mobx-react/__tests__/inject.test.tsx
+++ b/packages/mobx-react/__tests__/inject.test.tsx
@@ -296,7 +296,8 @@ describe("inject based context", () => {
expect(ref.current?.testField).toBe(1)
})
- test("propTypes and defaultProps are forwarded", () => {
+ // skipping because `propTypes` and `defaultProps` are dropped in React 19
+ test.skip("propTypes and defaultProps are forwarded", () => {
const msg: Array