Skip to content

Commit

Permalink
Add info about useAppDispatch to docs (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
IVIosi committed Oct 23, 2020
1 parent c4d81af commit 7eee197
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/using-react-redux/static-types.md
Expand Up @@ -80,6 +80,11 @@ export type AppDispatch = typeof store.dispatch
// MyComponent.tsx
const dispatch: AppDispatch = useDispatch()
```
You may also find it to be more convenient to export a hook like `useAppDispatch` shown below, then using it wherever you'd call `useDispatch`:
```ts
export type AppDispatch = typeof store.dispatch
export const useAppDispatch = () => useDispatch<AppDispatch>() // Export a hook that can be reused to resolve types
```

### Typing the `connect` higher order component

Expand Down

0 comments on commit 7eee197

Please sign in to comment.