首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在react-thunk中遇到的问题,请问这个是什么原因导致的?

在react-thunk中遇到的问题,请问这个是什么原因导致的?

提问于 2018-12-24 11:59:21
回答 0关注 0查看 360

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

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档