Created
February 13, 2020 09:27
-
-
Save zzdjk6/d11893aac2164ee6ed6eb10151811f68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Imagine we defined a thunk action creator from routine | |
| const fetchData = getThunkActionCreator(fetchDataRoutine, async (id: number) => { | |
| return await api.fetchData(id); | |
| }); | |
| // We could write another thunk action creator to access the existing state | |
| const fetchDataWithIdFromState = () => (dispatch: Dispatch, getState: () => RootState) => { | |
| const id = getState().somewhere.id; | |
| return dispatch(fetchData(id)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment