redux-thunk action creator code example
Example: redux-thunk action creator
/* Redux-Thunk Action Creator */
const createAction = () => { type: 'ACTION_TYPE' };
function createAsyncAction() {
return (dispatch) => {
setTimeout(() => {
dispatch(createAction());
/* ^ invoke sync or async actions with dispatch */
}, 1000);
}
}
/* About Redux-Thunk Actions
* redux-thunk allows you to write action creators
* that return a function instead of an action
*/