1

I'm working on a project with the React Redux Router, and am trying to change the page. When a component dispatches a "push" action, I see the "@@router/LOCATION_CHANGE" come through, but nothing changes.

I do have the routerMiddleware applied as well,

import thunk from 'redux-thunk';
import { routerMiddleware } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory'
import rootReducer from '../reducers';

export const history = createHistory();
const middleware = routerMiddleware(history)
export function configureStore(initialState) {
  return createStore(
    rootReducer,
    initialState,
    applyMiddleware(thunk),
    applyMiddleware(middleware)
  );
}

any thoughts as to what I'm doing incorrectly?

1
  • Not sure why, but it seems like switching the thunk and middleware lines fixes it? Would love an explanation as to why! Commented Feb 15, 2018 at 14:32

1 Answer 1

3

applyMiddleware expects a list of middlewares, so you're using it wrong: Please change it to:

export const history = createHistory();
const middleware = routerMiddleware(history)
export function configureStore(initialState) {
  return createStore(
    rootReducer,
    initialState,
    applyMiddleware(thunk,middleware)
  );
}

This also explains why switching them worked (the store received another middleware).

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.