Skip to content

Instantly share code, notes, and snippets.

@rfinni
Created November 30, 2016 02:19
Show Gist options
  • Select an option

  • Save rfinni/dd988121dedeebb15b84e46af28cd9cc to your computer and use it in GitHub Desktop.

Select an option

Save rfinni/dd988121dedeebb15b84e46af28cd9cc to your computer and use it in GitHub Desktop.
React-redux thunk example
export function someOtherAction(data) {
...
}
export function thunk(url) {
return function(dispatch, getState) {
return axios.get(url).then(data => {
dispatch(someOtherAction(data));
});
}
}
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