diff --git a/package.json b/package.json index 774a032fc..b44e6286b 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,8 @@ "eslint-plugin-react": "^7.34.2", "jsdom": "^25.0.1", "prettier": "^3.3.3", - "react": "^19.0.0", - "react-dom": "^19.0.0", + "react": "^19.2.0", + "react-dom": "^19.2.0", "redux": "^5.0.1", "rimraf": "^5.0.7", "tsup": "^8.3.5", diff --git a/src/components/connect.tsx b/src/components/connect.tsx index fc096d918..4b3bc06cc 100644 --- a/src/components/connect.tsx +++ b/src/components/connect.tsx @@ -249,6 +249,8 @@ export interface ConnectOptions< } /** + + * * Connects a React component to a Redux store. * * - Without arguments, just wraps the component, without changing the behavior / props @@ -415,6 +417,16 @@ export interface Connect { let hasWarnedAboutDeprecatedPureOption = false /** + * @deprecated + * + * **We recommend using the `useSelector` and `useDispatch` hooks instead.** + * See https://react-redux.js.org/api/hooks + * + * If you need to use `connect` without this visual deprecation warning, + * import `legacy_connect` instead: + * + * `import { legacy_connect as connect } from 'react-redux'` + * * Connects a React component to a Redux store. * * - Without arguments, just wraps the component, without changing the behavior / props @@ -434,7 +446,7 @@ let hasWarnedAboutDeprecatedPureOption = false * @param options Options for configuring the connection * */ -function connect< +function _connect< TStateProps = {}, TDispatchProps = {}, TOwnProps = {}, @@ -810,4 +822,24 @@ function connect< return wrapWithConnect } -export default connect as Connect +/** + * * @deprecated + * + * **We recommend using the `useSelector` and `useDispatch` hooks instead.** + * See https://react-redux.js.org/api/hooks + * + * If you need to use `connect` without this visual deprecation warning, + * import `legacy_connect` instead: + * + * `import { legacy_connect as connect } from 'react-redux'` + */ +export const connect: Connect = _connect as Connect + +/** + * Connects a React component to a Redux store. Same as `connect` but without + * the deprecation warning. + * + * **We recommend using the `useSelector` and `useDispatch` hooks instead.** + * See https://react-redux.js.org/api/hooks + */ +export const legacy_connect: Connect = _connect as Connect diff --git a/src/exports.ts b/src/exports.ts index f826f2d11..e3a027b08 100644 --- a/src/exports.ts +++ b/src/exports.ts @@ -1,4 +1,4 @@ -import connect from './components/connect' +import { connect, legacy_connect } from './components/connect' export type { Connect, ConnectProps, @@ -48,4 +48,4 @@ export * from './types' */ const batch = defaultNoopBatch -export { Provider, batch, connect, shallowEqual } +export { Provider, batch, connect, legacy_connect, shallowEqual } diff --git a/src/index-rsc.ts b/src/index-rsc.ts index b61fd623e..47722081e 100644 --- a/src/index-rsc.ts +++ b/src/index-rsc.ts @@ -23,6 +23,7 @@ export { throwNotSupportedError as Provider, throwNotSupportedError as batch, throwNotSupportedError as connect, + throwNotSupportedError as legacy_connect, throwNotSupportedError as createDispatchHook, throwNotSupportedError as createSelectorHook, throwNotSupportedError as createStoreHook, diff --git a/test/integration/ssr.spec.tsx b/test/integration/ssr.spec.tsx index 9af3e3e7b..1869b5b6d 100644 --- a/test/integration/ssr.spec.tsx +++ b/test/integration/ssr.spec.tsx @@ -174,7 +174,7 @@ describe('New v8 serverState behavior', () => { expect(consoleErrorSpy).toHaveBeenCalledOnce() expect(errorArg.message).toMatch( - /Hydration failed because the server rendered HTML didn't match the client/, + /Hydration failed because the server rendered (HTML|text) didn't match the client/, ) } else if (IS_REACT_18) { expect(consoleErrorSpy).toHaveBeenCalledTimes(8) diff --git a/yarn.lock b/yarn.lock index 6743badf8..0496f67f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4826,14 +4826,14 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^19.0.0": - version: 19.0.0 - resolution: "react-dom@npm:19.0.0" +"react-dom@npm:^19.2.0": + version: 19.2.3 + resolution: "react-dom@npm:19.2.3" dependencies: - scheduler: "npm:^0.25.0" + scheduler: "npm:^0.27.0" peerDependencies: - react: ^19.0.0 - checksum: 10/aa64a2f1991042f516260e8b0eca0ae777b6c8f1aa2b5ae096e80bbb6ac9b005aef2bca697969841d34f7e1819556263476bdfea36c35092e8d9aefde3de2d9a + react: ^19.2.3 + checksum: 10/5780f6d4c8e8ece09f82c5500ba2d55e01c30b5273f9281734d7d3b65013cd1fa52ec4e4436e5248c0a9e5bc340836044051168bbad8d7eac4d33ee6c2a867a1 languageName: node linkType: hard @@ -4882,8 +4882,8 @@ __metadata: eslint-plugin-react: "npm:^7.34.2" jsdom: "npm:^25.0.1" prettier: "npm:^3.3.3" - react: "npm:^19.0.0" - react-dom: "npm:^19.0.0" + react: "npm:^19.2.0" + react-dom: "npm:^19.2.0" redux: "npm:^5.0.1" rimraf: "npm:^5.0.7" tsup: "npm:^8.3.5" @@ -4903,10 +4903,10 @@ __metadata: languageName: unknown linkType: soft -"react@npm:^19.0.0": - version: 19.0.0 - resolution: "react@npm:19.0.0" - checksum: 10/2490969c503f644703c88990d20e4011fa6119ddeca451e9de48f6d7ab058d670d2852a5fcd3aa3cd90a923ab2815d532637bd4a814add402ae5c0d4f129ee71 +"react@npm:^19.2.0": + version: 19.2.3 + resolution: "react@npm:19.2.3" + checksum: 10/d16b7f35c0d35a56f63d9d1693819762e4abc479c57dd6310298920bed3820fcec7e17a99d44983416d8f5049143ea45b8005d3ab8324bae8973224400502b08 languageName: node linkType: hard @@ -5248,10 +5248,10 @@ __metadata: languageName: node linkType: hard -"scheduler@npm:^0.25.0": - version: 0.25.0 - resolution: "scheduler@npm:0.25.0" - checksum: 10/e661e38503ab29a153429a99203fefa764f28b35c079719eb5efdd2c1c1086522f6653d8ffce388209682c23891a6d1d32fa6badf53c35fb5b9cd0c55ace42de +"scheduler@npm:^0.27.0": + version: 0.27.0 + resolution: "scheduler@npm:0.27.0" + checksum: 10/eab3c3a8373195173e59c147224fc30dabe6dd453f248f5e610e8458512a5a2ee3a06465dc400ebfe6d35c9f5b7f3bb6b2e41c88c86fd177c25a73e7286a1e06 languageName: node linkType: hard