Skip to content

Commit def0ce1

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into cut-down-on-resolutions
2 parents 9a82433 + d955fb2 commit def0ce1

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-17
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'

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9007,12 +9007,12 @@ __metadata:
90079007
linkType: hard
90089008

90099009
"@types/react@npm:*, @types/react@npm:^18.0, @types/react@npm:^18.0.12, @types/react@npm:^18.0.5, @types/react@npm:^18.2.77":
9010-
version: 18.2.77
9011-
resolution: "@types/react@npm:18.2.77"
9010+
version: 18.3.1
9011+
resolution: "@types/react@npm:18.3.1"
90129012
dependencies:
90139013
"@types/prop-types": "npm:*"
90149014
csstype: "npm:^3.0.2"
9015-
checksum: 10/80d7ad9cf13e15895a857c66f5b0c1ce758c1e7580a76936d8d1b19c71e4485fa4b35d762a1de98de4eb91506cbc8507582c9a979f357b6f5f75f86009d8ca07
9015+
checksum: 10/baa6b8a75c471c89ebf3477b4feab57102ced25f0c1e553dd04ef6a1f0def28d5e0172fa626a631f22e223f840b5aaa2403b2d4bb671c83c5a9d6c7ae39c7a05
90169016
languageName: node
90179017
linkType: hard
90189018

@@ -24655,11 +24655,11 @@ __metadata:
2465524655
linkType: hard
2465624656

2465724657
"react@npm:^18.1.0, react@npm:^18.2.0":
24658-
version: 18.2.0
24659-
resolution: "react@npm:18.2.0"
24658+
version: 18.3.1
24659+
resolution: "react@npm:18.3.1"
2466024660
dependencies:
2466124661
loose-envify: "npm:^1.1.0"
24662-
checksum: 10/b9214a9bd79e99d08de55f8bef2b7fc8c39630be97c4e29d7be173d14a9a10670b5325e94485f74cd8bff4966ef3c78ee53c79a7b0b9b70cba20aa8973acc694
24662+
checksum: 10/261137d3f3993eaa2368a83110466fc0e558bc2c7f7ae7ca52d94f03aac945f45146bd85e5f481044db1758a1dbb57879e2fcdd33924e2dde1bdc550ce73f7bf
2466324663
languageName: node
2466424664
linkType: hard
2466524665

0 commit comments

Comments
 (0)