/禾斗匕匕/g
2018-12-24 12:56我在redux中添加了redux-thunk,在dispath中执行return一个action的函数还是报错
import {createStore,compose,applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import reducer from '../Reducer/index'
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose;
const enhancer = composeEnhancers(
applyMiddleware(thunk)
);
const store = createStore(reducer, enhancer);
export default store;
这是store的配置 中间件使用了thunk
function mapdispatchtoprops(dispatch){
return{
setLoginState:dispatch(login(token))
}
}
export default connect(null,mapdispatchtoprops)(withRouter(Login));
这是component中的使用
const login = (token)=>{
return {
type:'login',token:token,loginStatus:true
}
}
const loginAction = (token) => dispatch =>{
if(Object.getOwnPropertyNames(token).length > 0 ){
dispatch(login(token))
}else{
return false;
}
}
export default {loginAction,login}
这是自定的action
在component在执行报错:
Uncaught TypeError: Object(...) is not a function
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- DataTable在数据更改时不会更新
- javascript
- ajax
- php
- 3个回答
- 如何在do_shortcode之间添加php echo
- wordpress
- echo
- php
- 1个回答
- WordPress中的动态自定义代码转义
- javascript
- wordpress
- php
- 1个回答
- 将字段(标题/描述)添加到wordpress - Redux插件
- wordpress
- arrays
- php
- 1个回答
- dva.js怎么异步获取接口数据
- react.js
- 1个回答