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.

Stale props issue in selector API

See original GitHub issue

Thanks so much to https://github.com/reduxjs/react-redux/issues/1179#issuecomment-483617153, it explains better to understand.

So, as long as we use useReduxState(), we are safe, but with selectors there could be inconsistencies. In our case, it’s useReduxSelectors().

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dai-shicommented, Apr 25, 2019

I guess the discussion in https://github.com/reduxjs/react-redux/issues/1252 explains it.


So, in conclusion, our useReduxState doesn’t have stale props issue because it doesn’t remember anything, and useReduxSelectors has the issue as well as the official react-redux hooks (and probably all other unofficial hooks) which we’d basically live with as a limitation.

@faceyspacey You asked somewhere for the clarification, here it is.

0reactions
dai-shicommented, Apr 19, 2019

if you have many independent connected components in the tree

This totally explains. Thanks a lot.


While you are here, do you think react-redux v7 accepts this stale props issue as a limitation of hooks api? I think your proposal is the best so far and it’s silly to introduce hoc to solve the stale props issue. It would have been nice if the state context (aka v6) were possible, but it not likely to happen in the foreseeable future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hooks - React Redux
Hooks. React's new "hooks" APIs give function components the ability to use local component state, execute side effects, and more.
Read more >
Dealing With Stale Props and States in React's Functional ...
Long story short: it's when code that is executed asynchronously has a reference to a prop or state that is no longer fresh,...
Read more >
Stale props and zombie children in Redux | Kai Hao
The problem​​ Stale props means any case where: a selector function relies on this component's props to extract data. a parent component would...
Read more >
React/Redux, useEffect/useSelector, stale closures and event ...
A working solution is to pass it the selector as a dependency – however, this results in the listener being removed/re-added every time...
Read more >
Using the React-Redux Hooks API to Manipulate Store State
Stale props mean that a selector function relies on a component's props to extract data, a parent component would re-render and pass down ......
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