React本机Redux错误:类型错误:(0,import_redux2.combineReducers)不是一个函数

ljo96ir5  于 2022-11-12  发布在  React
关注(0)|答案(2)|浏览(109)

下面是一个错误,这是驱动我的墙壁,我已经改变了项目的名称,这是以前redux,它现在是全球管理系统,但我仍然不能让它工作.错误详细信息:类型错误:(0,import_redux2.combineReducers)不是一个函数。(在“(0,import_redux2.combineReducers)(reducer)”中,“(0,import_redux2.combineReducers)"未定义)

//store.js
    import { configureStore } from "@reduxjs/toolkit";
    import taskReducer from './taskSlice'

import { combineReducers } from 'redux' 

export default configureStore({
    reducer:{
    tasks:taskReducer
    }
})

//taskSlice.js
    import { createSlice } from "@reduxjs/toolkit";

export const taskSlice = createSlice({
    name:"tasks",
    initialState:[],
    reducers:{
        addTask:(state,action) => {
            const newTask = {
                id:action.payload.id,
                name:action.payload.id,
            };
            state.push(newTask)
        },
        deleteTask:(state,action) => {
            return state.filter((item) => item.id !== action.payload.id)
        },
    },
});

export const {addTask, deleteTask} = taskSlice.actions;

export default taskSlice.reducer;

//Package.json

    {
  "name": "global-management-system",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/vector-icons": "^13.0.0",
    "@reduxjs/toolkit": "^1.8.5",
    "expo": "~46.0.9",
    "expo-status-bar": "~1.4.0",
    "react": "18.0.0",
    "react-native": "0.69.5",
    "react-redux": "8.0",
    "redux": "^4.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}
gev0vcfq

gev0vcfq1#

显示的错误是由于导入了combineReducers

import { combineReducers } from 'redux'

看看代码,我想我没有看到任何其他问题。

eagi6jfj

eagi6jfj2#

import { combineReducers, configureStore } from "@reduxjs/toolkit";形式导入组合减速器

相关问题