New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using combinedReducers creates invalid reducers #2

Open
david-j-davis opened this Issue Oct 22, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@david-j-davis

david-j-davis commented Oct 22, 2018

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?

@NickDelfino

This comment has been minimized.

Owner

NickDelfino commented Oct 23, 2018

Hi David,

Thanks for the question!

This is a really interesting implementation question. At first glance, nothing is jumping out at me as wrong from the code provided. Were any changes made to the PostReducer?

If you want to upload your changes to GitHub I could run them locally and see if I can get to the bottom of it. Thanks!

Best,
Nick

@david-j-davis

This comment has been minimized.

david-j-davis commented Oct 23, 2018

No changes to PostReducer. I think it's because combineReducers is oppinionated. Im going to submit a pull request for your review.

@NickDelfino

This comment has been minimized.

Owner

NickDelfino commented Oct 23, 2018

Sounds great! Thanks for looking into this!

@david-j-davis

This comment has been minimized.

david-j-davis commented Oct 24, 2018

As you can tell, I didnt change much of the code but the combinereducer function breaks the build. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment