Skip to content
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
Open

Using combinedReducers creates invalid reducers #2

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

Comments

@david-j-davis
Copy link

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
Copy link
Owner

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
Copy link
Author

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

@NickDelfino
Copy link
Owner

Sounds great! Thanks for looking into this!

@david-j-davis
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants