Skip to content

Commit 7cf1383

Browse files
committed
Add hooks.withTypes() to docs
1 parent 4360ff4 commit 7cf1383

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/tutorials/typescript.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ While it's possible to import the `RootState` and `AppDispatch` types into each
7979
Since these are actual variables, not types, it's important to define them in a separate file such as `app/hooks.ts`, not the store setup file. This allows you to import them into any component file that needs to use the hooks, and avoids potential circular import dependency issues.
8080
8181
```ts title="app/hooks.ts"
82-
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
82+
import { useDispatch, useSelector } from 'react-redux'
8383
import type { RootState, AppDispatch } from './store'
8484

8585
// highlight-start
8686
// Use throughout your app instead of plain `useDispatch` and `useSelector`
87-
export const useAppDispatch: () => AppDispatch = useDispatch
88-
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
87+
export const useAppDispatch = useDispatch.withTypes<RootState>()
88+
export const useAppSelector = useSelector.withTypes<RootState>()
8989
// highlight-end
9090
```
9191

docs/using-react-redux/usage-with-typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ import type { RootState, AppDispatch } from './store'
6969

7070
// highlight-start
7171
// Use throughout your app instead of plain `useDispatch` and `useSelector`
72-
export const useAppDispatch: () => AppDispatch = useDispatch
73-
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
72+
export const useAppDispatch = useDispatch.withTypes<RootState>()
73+
export const useAppSelector = useSelector.withTypes<RootState>()
7474
// highlight-end
7575
```
7676

0 commit comments

Comments
 (0)