Reputation: 6027
According to the documentation I should be able to fire a LOCATION_CHANGE
event by calling push('/with/the/path')
. Example from docs:
import { routerMiddleware, push } from 'react-router-redux'
// Apply the middleware to the store
const middleware = routerMiddleware(browserHistory)
const store = createStore(
reducers,
applyMiddleware(middleware)
)
// Dispatch from anywhere like normal.
store.dispatch(push('/foo'))
However, this looks like when I call push I'm getting this (which doesn't look like it's doing anything):
What am I missing?
Upvotes: 2
Views: 2747
Reputation: 5488
Make sure to sync your history with your store. The following is an example setup:
import { routerMiddleware, syncHistoryWithStore, push } from 'react-router-redux'
// Apply the middleware to the store
const router = routerMiddleware(browserHistory)
const store = createStore(
reducers,
applyMiddleware(router)
)
const history = syncHistoryWithStore(browserHistory, store)
// Dispatch from anywhere like normal.
store.dispatch(push('/foo'))
Notice the bit about syncHistoryWithStore
after you create the store.
Hope this helps.
Upvotes: 2