-
import { combineReducers } from 'redux' import countReducer from './modules/count' export const IndexReducers =combineReducers({ countReducer })
2.同步Action
export const increment = value => ({ type: INCREMENT, value }) export const decement = value => ({ type: DECAMENT, value })
-
异步Action:
我在使用redux过程中遇到Actions must be plain objects. Use custom middleware for async actions.异常的分析 //异步Action任务 export const AsyncIncremnet=(data,time)=>{ return ()=>{ setTimeout(()=>{ Store.dispatch(increment(10)) },time) } } //redux不支持传递函数的Action如果必必须那就加上redux-thunk来实现
完整redux
-
import { INCREMENT, DECAMENT } from "../reducers"; //无法使{}直接加上()//这是同步Action export const increment
react中使用redux的combineReducersh合并reducer编写异步Action任务
最新推荐文章于 2022-05-03 23:08:01 发布