redux icon indicating copy to clipboard operation
redux copied to clipboard

Document usage of selectFromState thunk

Open EskiMojo14 opened this issue 2 years ago • 0 comments

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 :)

EskiMojo14 avatar Jan 16 '23 16:01 EskiMojo14