reactjs - What is the use of Redux-Router in addition to reac-router? -


guys. when go through documentation of redux-router, cannot understand why need it?

here documentation trying explain:

react router fantastic routing library, 1 downside abstracts away crucial piece of application state — current route! abstraction super useful route matching , rendering, api interacting router 1) trigger transitions , 2) react state changes within component lifecycle leaves desired.

it turns out solved these problems flux (and redux): use action creators trigger state changes, , use higher-order components subscribe state changes.

this library allows keep router state inside redux store. getting current pathname, query, , params easy selecting other part of application state.

as far can understand, trying redux router can keep router state inside redux store can route info more conveniently.

but within react-router, can it. path="messages/:id", can use this.props.params.id params.

can explain in scenario redux-router bring benefit?

redux (and in general, flux pattern) having entire application state stored in 1 central place. has benefit of easier debugging , makes easier implement features.

if you've ever used redux-devtools in react app react-router, you'll notice of limited use, because can't replay entire lifecycle of application. when user changes routes, that's not recorded in redux store. redux router keeps route state in store.

you use debugging, serialise entire store history , log elsewhere replay user sessions. hook implement full undo, or log analytics events.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -