Skip to content

Commit f2f09a9

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into remove-react-redux-from-resolutions
2 parents 1496b0a + d955fb2 commit f2f09a9

File tree

6 files changed

+42
-29
lines changed

6 files changed

+42
-29
lines changed

docs/rtk-query/usage-with-typescript.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ When using `fetchBaseQuery`, the `error` property returned from a hook will have
593593
If an error is present, you can access error properties after narrowing the type to either `FetchBaseQueryError` or `SerializedError`.
594594

595595
```tsx no-transpile
596-
import { api } from './services/api'
596+
import { usePostsQuery } from './services/api'
597597

598598
function PostDetail() {
599599
const { data, error, isLoading } = usePostsQuery()
@@ -613,10 +613,9 @@ function PostDetail() {
613613
<div>{errMsg}</div>
614614
</div>
615615
)
616-
} else {
617-
// you can access all properties of `SerializedError` here
618-
return <div>{error.message}</div>
619-
}
616+
}
617+
// you can access all properties of `SerializedError` here
618+
return <div>{error.message}</div>
620619
}
621620

622621
if (data) {

examples/query/react/basic/src/test/test-utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { render } from '@testing-library/react'
22
import type { RenderOptions } from '@testing-library/react'
3-
import React, { PropsWithChildren } from 'react'
3+
import type React from 'react'
4+
import type { PropsWithChildren, JSX } from 'react'
45
import { Provider } from 'react-redux'
56
import { setupStore } from '../store'
67
import type { AppStore, RootState } from '../store'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
"@babel/types": "7.19.3",
5252
"esbuild": "0.19.7",
5353
"jest-snapshot": "29.3.1",
54-
"react": "npm:18.2.0",
54+
"react": "npm:^18.2.0",
5555
"react-dom": "npm:18.2.0",
5656
"resolve": "1.22.1",
57-
"@types/react": "npm:18.0.12",
57+
"@types/react": "npm:^18.0.12",
5858
"@types/react-dom": "npm:18.0.5",
5959
"@types/inquirer": "npm:8.2.1",
6060
"website/react": "npm:17.0.2",

packages/toolkit/src/query/react/buildHooks.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,15 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
740740
Definitions
741741
>
742742
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>()
743-
const subscriptionSelectorsRef = useRef<SubscriptionSelectors>()
743+
744+
// TODO: Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
745+
/**
746+
* @todo Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
747+
*/
748+
const subscriptionSelectorsRef = useRef<
749+
SubscriptionSelectors | undefined
750+
>(undefined)
751+
744752
if (!subscriptionSelectorsRef.current) {
745753
const returnedValue = dispatch(
746754
api.internalActions.internal_getRTKQSubscriptions(),
@@ -781,7 +789,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
781789

782790
const lastRenderHadSubscription = useRef(false)
783791

784-
const promiseRef = useRef<QueryActionCreatorResult<any>>()
792+
// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
793+
/**
794+
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
795+
*/
796+
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
797+
undefined,
798+
)
785799

786800
let { queryCacheKey, requestId } = promiseRef.current || {}
787801

@@ -886,7 +900,14 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
886900
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>()
887901

888902
const [arg, setArg] = useState<any>(UNINITIALIZED_VALUE)
889-
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>()
903+
904+
// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
905+
/**
906+
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
907+
*/
908+
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
909+
undefined,
910+
)
890911

891912
const stableSubscriptionOptions = useShallowStableValue({
892913
refetchOnReconnect,
@@ -966,7 +987,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
966987

967988
type ApiRootState = Parameters<ReturnType<typeof select>>[0]
968989

969-
const lastValue = useRef<any>()
990+
const lastValue = useRef<any>(undefined)
970991

971992
const selectDefaultResult: Selector<ApiRootState, any, [any]> = useMemo(
972993
() =>

website/src/theme/DocPage/Layout/Main/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ComponentProps } from 'react'
1+
import type { ComponentProps, JSX } from 'react'
22
import React from 'react'
33
import Main from '@theme-original/DocPage/Layout/Main'
44
import type MainType from '@theme-original/DocPage/Layout/Main'

yarn.lock

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8889,14 +8889,13 @@ __metadata:
88898889
languageName: node
88908890
linkType: hard
88918891

8892-
"@types/react@npm:18.0.12":
8893-
version: 18.0.12
8894-
resolution: "@types/react@npm:18.0.12"
8892+
"@types/react@npm:^18.0.12":
8893+
version: 18.3.1
8894+
resolution: "@types/react@npm:18.3.1"
88958895
dependencies:
88968896
"@types/prop-types": "npm:*"
8897-
"@types/scheduler": "npm:*"
88988897
csstype: "npm:^3.0.2"
8899-
checksum: 10/b010b0d300555a8f70f0513b79d5c35400500cbada71303bbeb72167ddf6154803f92a2edab923c7460a2f1eaa430658b88953ca4a5fe08b276c3587ec91f4f7
8898+
checksum: 10/baa6b8a75c471c89ebf3477b4feab57102ced25f0c1e553dd04ef6a1f0def28d5e0172fa626a631f22e223f840b5aaa2403b2d4bb671c83c5a9d6c7ae39c7a05
89008899
languageName: node
89018900
linkType: hard
89028901

@@ -8934,13 +8933,6 @@ __metadata:
89348933
languageName: node
89358934
linkType: hard
89368935

8937-
"@types/scheduler@npm:*":
8938-
version: 0.16.1
8939-
resolution: "@types/scheduler@npm:0.16.1"
8940-
checksum: 10/709f02113c64289a03b15b7ecd541b1846caa224dacaf506f93b6931ec88b8c33e435122303e54e4501eecc9671817e133c3e98377c3751d8e0eb5019bd2bd35
8941-
languageName: node
8942-
linkType: hard
8943-
89448936
"@types/semver@npm:^7.3.12, @types/semver@npm:^7.5.0":
89458937
version: 7.5.6
89468938
resolution: "@types/semver@npm:7.5.6"
@@ -24490,12 +24482,12 @@ __metadata:
2449024482
languageName: node
2449124483
linkType: hard
2449224484

24493-
"react@npm:18.2.0":
24494-
version: 18.2.0
24495-
resolution: "react@npm:18.2.0"
24485+
"react@npm:^18.2.0":
24486+
version: 18.3.1
24487+
resolution: "react@npm:18.3.1"
2449624488
dependencies:
2449724489
loose-envify: "npm:^1.1.0"
24498-
checksum: 10/b9214a9bd79e99d08de55f8bef2b7fc8c39630be97c4e29d7be173d14a9a10670b5325e94485f74cd8bff4966ef3c78ee53c79a7b0b9b70cba20aa8973acc694
24490+
checksum: 10/261137d3f3993eaa2368a83110466fc0e558bc2c7f7ae7ca52d94f03aac945f45146bd85e5f481044db1758a1dbb57879e2fcdd33924e2dde1bdc550ce73f7bf
2449924491
languageName: node
2450024492
linkType: hard
2450124493

0 commit comments

Comments
 (0)