当前位置: 首页 > 工具软件 > astore > 使用案例 >

TypeError: store.getState is not a function

公羊嘉
2023-12-01

原src下的store的js文件,运行后报错

import { createStore } from "redux";

const notices = (state = {isAllRead: false,count:8},action)=>{
    switch (action.type) {
        case "READ_ALL":
            
            return{...state,isAllRead:true};
    
        default:
            return state;
    }
};

const store = createStore(notices)

export default store ;

报错TypeError: store.getState is not a function

修改以上代码

import { createStore } from "redux";

function notices(state={isAllRead: false,count:8},action){
    switch (action.type) {
        case 'READ_ALL':
            
            return {...state,isAllRead:true};
    
        default:
            break;
    }
}
const store = createStore(notices)

export default store ;

可能第一个代码块定义的state方式老了不支持了

 类似资料:

相关阅读

相关文章

相关问答