question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add TypedUseDispatchHook interface for typing and using with middlewares like redux thunk

See original GitHub issue

Do 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
IVIosicommented, Oct 22, 2020

@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.

1reaction
markeriksoncommented, Oct 22, 2020

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 use useAppDispatch everywhere.

Copying @phryneas , our resident TS expert.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found