Open
Description
opened on 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 :)
Activity