Closed martinwells closed 8 years ago
Untested, but you may use scroll-behavior npm module to do this:
import createHistory from 'history/lib/createBrowserHistory'
import useScroll from 'scroll-behavior/lib/useScrollToTop'
// Compose reduxReactRouter with other store enhancers
const store = compose(
applyMiddleware(m1, m2, m3),
reduxReactRouter({
routes,
createHistory: useScroll(createHistory)
}),
devTools()
)(createStore)(reducer)
@martinwells Not sure if @chentsulin's example worked but you could also write a custom middleware which inspects the action, checks the type against the routerDidChange type from redux-router
and then do the window.scroll
Hi there,
I would like to add a basic hook that does a: window.scrollTo(0, 0); whenever there is a route change. Any ideas where I could place this?