我們在項目經常要發送ajax,處理異步等,這個也可以使用中間件
第一步:安裝
第二步: 使用
第三步:action代碼
import { INCREMENT, DECREMENT } from '../constants';
export const increment = () => {
return dispatch => {
setTimeout(() => {
dispatch({
type: INCREMENT
});
}, 2000);
};
};