Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-redux: Compat with React 19 types #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/node": "^20.11.6",
"@types/react": "18.2.25",
"@types/prop-types": "^15.7.12",
"@types/react": "npm:[email protected]",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"babel-eslint": "^10.1.0",
Expand All @@ -110,5 +111,9 @@
"typescript": "^5.4.2",
"vitest": "^1.2.1"
},
"resolutions": {
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
},
"packageManager": "[email protected]"
}
6 changes: 3 additions & 3 deletions src/components/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,13 +641,13 @@ function connect<
}, [didStoreComeFromProps, contextValue, subscription])

// Set up refs to coordinate values between the subscription effect and the render logic
const lastChildProps = React.useRef<unknown>()
const lastChildProps = React.useRef<unknown>(undefined)
const lastWrapperProps = React.useRef(wrapperProps)
const childPropsFromStoreUpdate = React.useRef<unknown>()
const childPropsFromStoreUpdate = React.useRef<unknown>(undefined)
const renderIsScheduled = React.useRef(false)
const isMounted = React.useRef(false)

const latestSubscriptionCallbackError = React.useRef<Error>()
const latestSubscriptionCallbackError = React.useRef<Error>(undefined)

useIsomorphicLayoutEffect(() => {
isMounted.current = true
Expand Down
2 changes: 1 addition & 1 deletion test/components/Provider.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*eslint-disable react/prop-types*/

import * as rtl from '@testing-library/react'
import type { Dispatch } from 'react'
import type { Dispatch, JSX } from 'react'
import React, { Component } from 'react'
import type { Store } from 'redux'
import { createStore } from 'redux'
Expand Down
2 changes: 1 addition & 1 deletion test/components/connect.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*eslint-disable react/prop-types*/

import * as rtl from '@testing-library/react'
import type { Dispatch, ElementType, MouseEvent, ReactNode } from 'react'
import type { Dispatch, ElementType, MouseEvent, ReactNode, JSX } from 'react'
import React, { Component } from 'react'
import type {
Action,
Expand Down
3 changes: 2 additions & 1 deletion test/typetests/connect-options-and-issues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,15 @@ function testRef() {
></ConnectedForwardedFunctionalComponent>

// Should be able to use all refs including legacy string
const classLegacyRef: React.LegacyRef<ClassComponent> | undefined = undefined
const classLegacyRef: React.Ref<ClassComponent> | undefined = undefined
;<ConnectedClassComponent ref={classLegacyRef}></ConnectedClassComponent>
;<ConnectedClassComponent
ref={React.createRef<ClassComponent>()}
></ConnectedClassComponent>
;<ConnectedClassComponent
ref={(ref: ClassComponent) => {}}
></ConnectedClassComponent>
// @ts-expect-error String refs are no longer supported in React 19.
;<ConnectedClassComponent ref={''}></ConnectedClassComponent>
// ref type should be the typeof the wrapped component
;<ConnectedClassComponent
Expand Down
39 changes: 14 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2355,41 +2355,29 @@ __metadata:
languageName: node
linkType: hard

"@types/prop-types@npm:*":
version: 15.7.4
resolution: "@types/prop-types@npm:15.7.4"
checksum: 10/ef6e1899e59b876c273811b1bd845022fc66d5a3d11cb38a25b6c566b30514ae38fe20a40f67622f362a4f4f7f9224e22d8da101cff3d6e97e11d7b4c307cfc1
"@types/prop-types@npm:^15.7.12":
version: 15.7.12
resolution: "@types/prop-types@npm:15.7.12"
checksum: 10/ac16cc3d0a84431ffa5cfdf89579ad1e2269549f32ce0c769321fdd078f84db4fbe1b461ed5a1a496caf09e637c0e367d600c541435716a55b1d9713f5035dfe
languageName: node
linkType: hard

"@types/react-dom@npm:^18.0.0":
version: 18.2.18
resolution: "@types/react-dom@npm:18.2.18"
"@types/react-dom@npm:types-react-dom@19.0.0-alpha.2":
version: 19.0.0-alpha.2
resolution: "types-react-dom@npm:19.0.0-alpha.2"
dependencies:
"@types/react": "npm:*"
checksum: 10/4ef7725b4cebd4a32e049097ddfdfd855a178e63ead97ab6d3084872e7d6c1acd71aa923488123cd1015f0e0b11489d2b44f674a1df8fe82d7827eabbec6dbf1
checksum: 10/8eab207af2c76789bddb42791cd659144e09165d72a35b13623e3c0cf619cef0e9586b94e5a866778cba7d2f404526822503de4ddbbcf24891af3f507430f0f1
languageName: node
linkType: hard

"@types/react@npm:*":
version: 18.2.41
resolution: "@types/react@npm:18.2.41"
"@types/react@npm:[email protected]":
version: 19.0.0-alpha.2
resolution: "types-react@npm:19.0.0-alpha.2"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10/31a498a56ad3e825ae13799355fe49042c0cdbbe6f40003f39b6b9cf847ba1669393c22ba60e97b1072cf1c002b15432082cdd17e47c948430bdc1f0864829b9
languageName: node
linkType: hard

"@types/react@npm:18.2.25":
version: 18.2.25
resolution: "@types/react@npm:18.2.25"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10/e777471a58bde47a710c7a1906eb9fcafa793671179fc9c0187694f916da043adac5ebd4b87c8cc14c42fd4979376e7a6acabae02b99450c2a5e198155880161
checksum: 10/165c61c0d0e9c2679534ff9ea6711712153c6df17633b9527cca2540adfe330c5eca54800fd97db2755fb8caa25e9d48d73d5626ee05a54563e7cc725f354f6f
languageName: node
linkType: hard

Expand Down Expand Up @@ -7131,7 +7119,8 @@ __metadata:
"@testing-library/react": "npm:^14.1.2"
"@testing-library/react-hooks": "npm:^8.0.1"
"@types/node": "npm:^20.11.6"
"@types/react": "npm:18.2.25"
"@types/prop-types": "npm:^15.7.12"
"@types/react": "npm:[email protected]"
"@types/use-sync-external-store": "npm:^0.0.3"
"@typescript-eslint/eslint-plugin": "npm:^6.17.0"
"@typescript-eslint/parser": "npm:^6.17.0"
Expand Down
Loading