Combine Reducers does not work in store,and does not send data to Components in Redux-React

I am new on redux.I want to implement redux on react. I have created todo list and it is working well with redux.As a practice I have created a new component called Calculate to increase and decrease a number under the todo list.I have two reducer for that.I combined two reducers in index.js.But as far as I understand combining is not working. I face with error like that "
TypeError: this.props.messages.map is not a function".But when without combining the reducers,and sending only messaageReducer to store, my app working well.Here is my code.

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import messageReducer from "./reducers/reducers"
import {Provider} from "react-redux"
import {combineReducers, createStore} from "redux"
import Calculate from "./calculate"
import counter from "./reducers/reducers2"



const rootReducer = combineReducers({
  counter,
  messageReducer,
 
})

const store = createStore(rootReducer)

ReactDOM.render(
  <Provider store={store}>
    <App />
    <Calculate/>
  </Provider>,
  document.getElementById('root')
);

hi, `combineReducers takes in an object, that means each entry within it must be a key-value pair, with the key being the state being managed by the reducer. Example:

const supaReducer=combineReducers ({
  state1:state1Reducer,
  state2:state2Reducer
})

The exception is when the reducer is named after the state slices it manages, only then can you use a shorthand like you did.

See more on the redux doc page here

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.