redux thunk implementation code example
Example 1: redux thunk
npm install redux-thunk
Example 2: thunk redux
npm install --save redux-thunk
Example 3: redux-thunk example
const INCREMENT_COUNTER = 'INCREMENT_COUNTER';
function increment() {
return {
type: INCREMENT_COUNTER
};
}
function incrementAsync() {
return dispatch => {
setTimeout(() => {
// You can invoke sync or async actions with `dispatch`
dispatch(increment());
}, 1000);
};
}