Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit int…
Browse files Browse the repository at this point in the history
…o remove-react-redux-from-resolutions
  • Loading branch information
aryaemami59 committed May 1, 2024
2 parents 1496b0a + d955fb2 commit f2f09a9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 29 deletions.
9 changes: 4 additions & 5 deletions docs/rtk-query/usage-with-typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ When using `fetchBaseQuery`, the `error` property returned from a hook will have
If an error is present, you can access error properties after narrowing the type to either `FetchBaseQueryError` or `SerializedError`.

```tsx no-transpile
import { api } from './services/api'
import { usePostsQuery } from './services/api'

function PostDetail() {
const { data, error, isLoading } = usePostsQuery()
Expand All @@ -613,10 +613,9 @@ function PostDetail() {
<div>{errMsg}</div>
</div>
)
} else {
// you can access all properties of `SerializedError` here
return <div>{error.message}</div>
}
}
// you can access all properties of `SerializedError` here
return <div>{error.message}</div>
}

if (data) {
Expand Down
3 changes: 2 additions & 1 deletion examples/query/react/basic/src/test/test-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render } from '@testing-library/react'
import type { RenderOptions } from '@testing-library/react'
import React, { PropsWithChildren } from 'react'
import type React from 'react'
import type { PropsWithChildren, JSX } from 'react'
import { Provider } from 'react-redux'
import { setupStore } from '../store'
import type { AppStore, RootState } from '../store'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"@babel/types": "7.19.3",
"esbuild": "0.19.7",
"jest-snapshot": "29.3.1",
"react": "npm:18.2.0",
"react": "npm:^18.2.0",
"react-dom": "npm:18.2.0",
"resolve": "1.22.1",
"@types/react": "npm:18.0.12",
"@types/react": "npm:^18.0.12",
"@types/react-dom": "npm:18.0.5",
"@types/inquirer": "npm:8.2.1",
"website/react": "npm:17.0.2",
Expand Down
29 changes: 25 additions & 4 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,15 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
Definitions
>
const dispatch = useDispatch<ThunkDispatch<any, any, UnknownAction>>()
const subscriptionSelectorsRef = useRef<SubscriptionSelectors>()

// TODO: Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
/**
* @todo Change this to `useRef<SubscriptionSelectors>(undefined)` after upgrading to React 19.
*/
const subscriptionSelectorsRef = useRef<
SubscriptionSelectors | undefined
>(undefined)

if (!subscriptionSelectorsRef.current) {
const returnedValue = dispatch(
api.internalActions.internal_getRTKQSubscriptions(),
Expand Down Expand Up @@ -781,7 +789,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

const lastRenderHadSubscription = useRef(false)

const promiseRef = useRef<QueryActionCreatorResult<any>>()
// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
/**
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
*/
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
undefined,
)

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

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

const [arg, setArg] = useState<any>(UNINITIALIZED_VALUE)
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>()

// TODO: Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
/**
* @todo Change this to `useRef<QueryActionCreatorResult<any>>(undefined)` after upgrading to React 19.
*/
const promiseRef = useRef<QueryActionCreatorResult<any> | undefined>(
undefined,
)

const stableSubscriptionOptions = useShallowStableValue({
refetchOnReconnect,
Expand Down Expand Up @@ -966,7 +987,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

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

const lastValue = useRef<any>()
const lastValue = useRef<any>(undefined)

const selectDefaultResult: Selector<ApiRootState, any, [any]> = useMemo(
() =>
Expand Down
2 changes: 1 addition & 1 deletion website/src/theme/DocPage/Layout/Main/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentProps } from 'react'
import type { ComponentProps, JSX } from 'react'
import React from 'react'
import Main from '@theme-original/DocPage/Layout/Main'
import type MainType from '@theme-original/DocPage/Layout/Main'
Expand Down
24 changes: 8 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8889,14 +8889,13 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:18.0.12":
version: 18.0.12
resolution: "@types/react@npm:18.0.12"
"@types/react@npm:^18.0.12":
version: 18.3.1
resolution: "@types/react@npm:18.3.1"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10/b010b0d300555a8f70f0513b79d5c35400500cbada71303bbeb72167ddf6154803f92a2edab923c7460a2f1eaa430658b88953ca4a5fe08b276c3587ec91f4f7
checksum: 10/baa6b8a75c471c89ebf3477b4feab57102ced25f0c1e553dd04ef6a1f0def28d5e0172fa626a631f22e223f840b5aaa2403b2d4bb671c83c5a9d6c7ae39c7a05
languageName: node
linkType: hard

Expand Down Expand Up @@ -8934,13 +8933,6 @@ __metadata:
languageName: node
linkType: hard

"@types/scheduler@npm:*":
version: 0.16.1
resolution: "@types/scheduler@npm:0.16.1"
checksum: 10/709f02113c64289a03b15b7ecd541b1846caa224dacaf506f93b6931ec88b8c33e435122303e54e4501eecc9671817e133c3e98377c3751d8e0eb5019bd2bd35
languageName: node
linkType: hard

"@types/semver@npm:^7.3.12, @types/semver@npm:^7.5.0":
version: 7.5.6
resolution: "@types/semver@npm:7.5.6"
Expand Down Expand Up @@ -24490,12 +24482,12 @@ __metadata:
languageName: node
linkType: hard

"react@npm:18.2.0":
version: 18.2.0
resolution: "react@npm:18.2.0"
"react@npm:^18.2.0":
version: 18.3.1
resolution: "react@npm:18.3.1"
dependencies:
loose-envify: "npm:^1.1.0"
checksum: 10/b9214a9bd79e99d08de55f8bef2b7fc8c39630be97c4e29d7be173d14a9a10670b5325e94485f74cd8bff4966ef3c78ee53c79a7b0b9b70cba20aa8973acc694
checksum: 10/261137d3f3993eaa2368a83110466fc0e558bc2c7f7ae7ca52d94f03aac945f45146bd85e5f481044db1758a1dbb57879e2fcdd33924e2dde1bdc550ce73f7bf
languageName: node
linkType: hard

Expand Down

0 comments on commit f2f09a9

Please sign in to comment.