2
const rootReducer = combineReducers({
  router: routerStateReducer,
  todos,
})

const createStoreWithMiddleware = compose(
  applyMiddleware(thunk),
  reduxReactRouter({ routes, createHistory })
  )(createStore)(reducer);


export default function configureStore(initialState) {
  const store = createStoreWithMiddleware(rootReducer, initialState)

It is giving me createStoreWithMiddleware is not a function.. Why this ?

5
  • try using let, as opposed to const, and please let me know if the error changes for you Commented Jan 28, 2016 at 11:34
  • sorry no change.. I think the issue is somewhere else.. react-redux documentation has not pointed this out.. Commented Jan 28, 2016 at 11:37
  • Updated with solution Commented Jan 28, 2016 at 12:08
  • 1
    don't update the question with the answer :/ now we don't know if something is wrong or not. could you revert the changes and post an explained answer? Commented Jan 28, 2016 at 14:48
  • Yes, do not just overwrite the question with the answer as that will be more confusing to anyone in the future who looks at this post. Either edit your post with the solution below the faulty code or make an actual answer and accept it. Commented Jan 28, 2016 at 15:03

1 Answer 1

1

You're executing the result of compose (which returns a function). So instead of setting createStoreWithMiddleware to the returned function, you are setting it to the executed result with the variable reducer.

Not sure what the variable reducer in this context is since you have rootReducer defined above. Your code should probably read:

const createStoreWithMiddleware = compose(
  applyMiddleware(thunk),
  reduxReactRouter({ routes, createHistory })
)(createStore)

doing so will define createStoreWithMiddleware as an extended createStore function, which can then receive your rootReducer and initialState.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.