You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{applyMiddleware,createStore}from'redux'import{createMiddleware,History,match,navigate,reducer,route}from'redux-routing'// define routesconstroutes=[route('/',()=>console.log('navigated to /')),route('/foo',()=>console.log('navigated to /foo')),route('/foo/:bar',()=>console.log('navigated to /foo/:bar'))]// create routing middleware, set up with HTML5 Historyconstmiddleware=createMiddleware(History)// create store with middlewareconstcreateStoreWithMiddleware=applyMiddleware(middleware)(createStore)conststore=createStoreWithMiddleware(reducer)// subscribe to changesstore.subscribe(()=>{constroute=store.getState()constmatched=match(route.href,routes)if(matched){matched.handler()}else{console.log('404 not found')}})// start navigatingstore.dispatch(navigate('/'))// logs 'navigated to /'store.dispatch(navigate('/foo'))// logs 'navigated to /foo'store.dispatch(navigate('/foo/123'))// logs 'navigated to /foo/:bar'store.dispatch(navigate('/foo/bar/baz'))// logs '404 not found'
See path-parser for more detail on defining routes.