Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document usage of selectFromState thunk #4464

Open
EskiMojo14 opened this issue Jan 16, 2023 · 0 comments
Open

Document usage of selectFromState thunk #4464

EskiMojo14 opened this issue Jan 16, 2023 · 0 comments
Labels

Comments

@EskiMojo14
Copy link
Contributor

EskiMojo14 commented Jan 16, 2023

What docs page is being updated?

  • Section: Using Selectors with React-Redux
  • Page: Deriving Data with Selectors

What updates should be made to the page?

Adding documentation regarding the selectFromState thunk for selecting the most recent value from state when you only have access to dispatch, or want a one-time read from state without a subscription.

const selectFromState = <Selected>(selector: (state: RootState) => Selected): AppThunk<Selected> => (dispatch, getState) => selector(getState());

const users = dispatch(selectFromState(selectUsers));

Do these updates change any of the assumptions or target audience? If so, how do they change?

I don't think so - this is a pattern often advised to use to help people who need a one-shot selection rather than maintaining a subscription.

raising after discussion with @markerikson in Reactiflux :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants