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.

`TypedUseSelectorHook` is deprecated but official documentation still recommends using it

See original GitHub issue

The Static Typing documentation refers to the TypedUseSelectorHook helper type, but if you import it from @types/react-redux and hover over the import in VSCode, it’s marked as deprecated and you’re instructed to use createSelectorHook<State, Action>() instead. I can submit a PR to update this if needed.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
markeriksoncommented, May 18, 2021

Sure.

Purely as background, I think what happened was:

  • Our useSelector and useDispatch hooks rely on the singleton ReactReduxContext in our own library, as does connect
  • Some users pointed out that while connect allowed passing a custom context instance as a prop, there was no way to use a custom context instance with the hooks
  • We released new createSelectorHook and createDispatchHook APIs whose only purpose is to allow users to create a customized version of useSelector and useDispatch with their own custom context instance instead of ReactReduxContext
  • Some user out there saw those, and assumed that they were meant for a broader use case, like “create a general-purpose customized version of these hooks”, which is not correct
  • They decided to update the @types/react-redux package based on this wrong assumption

And so we had to step in and fix the incorrect update to the types.

0reactions
ldco2016commented, May 18, 2021

@markerikson , awesome, thats where the confusion lies. My colleague thinks its deprecated, but from reading this very issue that he himself shared with me, it seemed the other way around.

Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use of createSelectorHook instead of deprecated ...
@Daniel I found out that TypedUseSelectorHook was deprecated accidentally. It's recommended that you use TypedUseSelectorHook instead of ...
Read more >
Modern Redux with Redux Toolkit, June 2022 - Mark's Dev Blog
Configuring a Redux store is too complicated; Have to add a lot of packages to do anything useful ( redux-thunk , reselect ,...
Read more >
How to use Redux with TypeScript
In this small tutorial, I will show you how to use Redux with TypeScript. Disclaimer: I want to do this tutorial as a...
Read more >
Apr 12
We're tossing around the idea of marking `createStore` as deprecated. We have _no_ plans to remove it. But, we want to give people...
Read more >
Usage With TypeScript
There are multiple possible approaches to type checking Redux code. This page shows our standard recommended patterns for using Redux and ...
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