skip to Main Content

The following is an error that is driving me up the walls, I have changed the name of the project which was previously redux, it is now global-management-system but I still cannot get it to work.
Error Details:
TypeError: (0, import_redux2.combineReducers) is not a function. (In ‘(0, import_redux2.combineReducers)(reducer)’, ‘(0, import_redux2.combineReducers)’ is undefined)

 //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
}

2

Answers


  1. the error that is showing you is due to the import of combineReducers

    import { combineReducers } from 'redux'
    

    Taking a look at the code, I think I don’t see any more problems.

    Login or Signup to reply.
  2. Import combineReducers as import { combineReducers, configureStore } from "@reduxjs/toolkit";

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search