Add TypedUseDispatchHook interface for typing and using with middlewares like redux thunk
See original GitHub issueDo you want to request a feature or report a bug?
Feature
What is the expected behavior?
add an interface like TypedUseSelectorHook for useDispatch hook
Details
I think an interface for typing useDispatch
hook like what useSelector
hook has could be useful for many users who uses redux middlewares for async actions (e.g. redux thunk and etc.)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Add TypedUseDispatchHook interface for typing and using ...
Add TypedUseDispatchHook interface for typing and using with middlewares like redux thunk.
Read more >Usage With TypeScript - Redux
For useDispatch , the default Dispatch type does not know about thunks or other middleware. In order to correctly dispatch thunks, you need...
Read more >How to type redux thunk with middleware in typescript
The Redux docs "Usage with TypeScript" page specifically covers typing middleware and thunks: A custom middleware would look like:
Read more >Async actions in bare Redux with Thunk or custom middleware
Using Thunk and Redux Toolkit to manage asynchronous actions ... the UI connecting it to the Redux store, as the following code shows:...
Read more >How to Use Thunks with Redux Toolkit and TypeScript
All the work is done in the redux-thunk middleware. ... We could also use `as` to coerce its type ... Now, let's add...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@phryneas @markerikson @dai-shi Thanks for your comments. I found out there are different approaches for static typing. So no need for helper type I mentioned in the beginning.
Still not sure what you’re asking us to actually add beyond what that
useAppDispatch
example shows doing. The idea is that you’d import and useuseAppDispatch
everywhere.Copying @phryneas , our resident TS expert.