Created
November 30, 2016 02:19
-
-
Save rfinni/dd988121dedeebb15b84e46af28cd9cc to your computer and use it in GitHub Desktop.
React-redux thunk example
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
| export function someOtherAction(data) { | |
| ... | |
| } | |
| export function thunk(url) { | |
| return function(dispatch, getState) { | |
| return axios.get(url).then(data => { | |
| dispatch(someOtherAction(data)); | |
| }); | |
| } | |
| } |
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
| refresh(e) { | |
| e.preventDefault(); | |
| this.props.dispatch(thunk(url)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment