Skip to content

Commit 5d802e0

Browse files
committed
Add listenerMiddleware.withTypes to docs
1 parent fb02311 commit 5d802e0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

docs/api/createListenerMiddleware.mdx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,21 +486,16 @@ To fix this, the middleware provides types for defining "pre-typed" versions of
486486
```ts no-transpile
487487
// listenerMiddleware.ts
488488
import { createListenerMiddleware, addListener } from '@reduxjs/toolkit'
489-
import type { TypedStartListening, TypedAddListener } from '@reduxjs/toolkit'
490-
491489
import type { RootState, AppDispatch } from './store'
492490

493491
export const listenerMiddleware = createListenerMiddleware()
494492

495-
export type AppStartListening = TypedStartListening<RootState, AppDispatch>
496-
497-
export const startAppListening =
498-
listenerMiddleware.startListening as AppStartListening
499-
500-
export const addAppListener = addListener as TypedAddListener<
493+
export const startAppListening = listenerMiddleware.startListening.withTypes<
501494
RootState,
502495
AppDispatch
503-
>
496+
>()
497+
498+
export const addAppListener = addListener.withTypes<RootState, AppDispatch>()
504499
```
505500

506501
Then import and use those pre-typed methods in your components.

0 commit comments

Comments
 (0)