Skip to content

Using combinedReducers creates invalid reducers #2

Open
@david-j-davis

Description

@david-j-davis

Hey Nick, I've tested your code with the implementation of index.js inside /reducers with:

import { combineReducers } from "redux";
import PostReducer from './PostReducer'

export default combineReducers({
  PostReducer
})

And inside store.js:

import { createStore, applyMiddleware } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import reducer from './reducers/index';

export const initialState = {
  posts: [],
  userPost: ''
};

export const initStore = (initialState = initialState) => {
  return createStore(reducer, initialState, composeWithDevTools(applyMiddleware(thunkMiddleware)))
};

I'm getting the following error:
No reducer provided for key "PostReducer" Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers. TypeError: Cannot read property 'map' of undefined

Thoughts about the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions