Skip to content

Commit 3ea0e84

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into configs
2 parents 03ebe78 + d955fb2 commit 3ea0e84

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
@@ -56,10 +56,10 @@
5656
"esbuild": "0.19.7",
5757
"jest-snapshot": "29.3.1",
5858
"react-redux": "npm:9.1.0",
59-
"react": "npm:18.2.0",
59+
"react": "npm:^18.2.0",
6060
"react-dom": "npm:18.2.0",
6161
"resolve": "1.22.1",
62-
"@types/react": "npm:18.0.12",
62+
"@types/react": "npm:^18.0.12",
6363
"@types/react-dom": "npm:18.0.5",
6464
"@types/inquirer": "npm:8.2.1",
6565
"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
@@ -737,7 +737,15 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
737737
Definitions
738738
>
739739
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>()
740-
const subscriptionSelectorsRef = useRef<SubscriptionSelectors>()
740+
741+
// TODO: Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
742+
/**
743+
* @todo Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
744+
*/
745+
const subscriptionSelectorsRef = useRef<
746+
SubscriptionSelectors | undefined
747+
>(undefined)
748+
741749
if (!subscriptionSelectorsRef.current) {
742750
const returnedValue = dispatch(
743751
api.internalActions.internal_getRTKQSubscriptions(),
@@ -778,7 +786,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
778786

779787
const lastRenderHadSubscription = useRef(false)
780788

781-
const promiseRef = useRef<QueryActionCreatorResult<any>>()
789+
// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
790+
/**
791+
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
792+
*/
793+
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
794+
undefined,
795+
)
782796

783797
const { queryCacheKey, requestId } = promiseRef.current || {}
784798

@@ -883,7 +897,14 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
883897
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>()
884898

885899
const [arg, setArg] = useState<any>(UNINITIALIZED_VALUE)
886-
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>()
900+
901+
// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
902+
/**
903+
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
904+
*/
905+
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
906+
undefined,
907+
)
887908

888909
const stableSubscriptionOptions = useShallowStableValue({
889910
refetchOnReconnect,
@@ -963,7 +984,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
963984

964985
type ApiRootState = Parameters<ReturnType<typeof select>>[0]
965986

966-
const lastValue = useRef<any>()
987+
const lastValue = useRef<any>(undefined)
967988

968989
const selectDefaultResult: Selector<ApiRootState, any, [any]> = useMemo(
969990
() =>

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
@@ -9029,14 +9029,13 @@ __metadata:
90299029
languageName: node
90309030
linkType: hard
90319031

9032-
"@types/react@npm:18.0.12":
9033-
version: 18.0.12
9034-
resolution: "@types/react@npm:18.0.12"
9032+
"@types/react@npm:^18.0.12":
9033+
version: 18.3.1
9034+
resolution: "@types/react@npm:18.3.1"
90359035
dependencies:
90369036
"@types/prop-types": "npm:*"
9037-
"@types/scheduler": "npm:*"
90389037
csstype: "npm:^3.0.2"
9039-
checksum: 10/b010b0d300555a8f70f0513b79d5c35400500cbada71303bbeb72167ddf6154803f92a2edab923c7460a2f1eaa430658b88953ca4a5fe08b276c3587ec91f4f7
9038+
checksum: 10/baa6b8a75c471c89ebf3477b4feab57102ced25f0c1e553dd04ef6a1f0def28d5e0172fa626a631f22e223f840b5aaa2403b2d4bb671c83c5a9d6c7ae39c7a05
90409039
languageName: node
90419040
linkType: hard
90429041

@@ -9074,13 +9073,6 @@ __metadata:
90749073
languageName: node
90759074
linkType: hard
90769075

9077-
"@types/scheduler@npm:*":
9078-
version: 0.16.1
9079-
resolution: "@types/scheduler@npm:0.16.1"
9080-
checksum: 10/709f02113c64289a03b15b7ecd541b1846caa224dacaf506f93b6931ec88b8c33e435122303e54e4501eecc9671817e133c3e98377c3751d8e0eb5019bd2bd35
9081-
languageName: node
9082-
linkType: hard
9083-
90849076
"@types/semver@npm:^7.3.12":
90859077
version: 7.5.6
90869078
resolution: "@types/semver@npm:7.5.6"
@@ -24650,12 +24642,12 @@ __metadata:
2465024642
languageName: node
2465124643
linkType: hard
2465224644

24653-
"react@npm:18.2.0":
24654-
version: 18.2.0
24655-
resolution: "react@npm:18.2.0"
24645+
"react@npm:^18.2.0":
24646+
version: 18.3.1
24647+
resolution: "react@npm:18.3.1"
2465624648
dependencies:
2465724649
loose-envify: "npm:^1.1.0"
24658-
checksum: 10/b9214a9bd79e99d08de55f8bef2b7fc8c39630be97c4e29d7be173d14a9a10670b5325e94485f74cd8bff4966ef3c78ee53c79a7b0b9b70cba20aa8973acc694
24650+
checksum: 10/261137d3f3993eaa2368a83110466fc0e558bc2c7f7ae7ca52d94f03aac945f45146bd85e5f481044db1758a1dbb57879e2fcdd33924e2dde1bdc550ce73f7bf
2465924651
languageName: node
2466024652
linkType: hard
2466124653

0 commit comments

Comments
 (0)