1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Sync Your react-router State With Redux as a react til

This commit is contained in:
jbranchaud
2018-04-16 17:36:15 -05:00
parent 22b29c081b
commit 5de41a9000
2 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
# Sync Your react-router State With Redux
If you are building a React app that uses both `redux` and `react-router`,
you'll find that you are managing app state in two places. Most of your app
state is in `redux`. The router-specific state is component-state in the
`Router`.
You can unify it all in `redux` with
[`react-router-redux`](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux).
You'll need to apply some middleware, combine `routerReducer` with the rest
of your reducers, and then swap out your `BrowserRouter` with a
`ConnectedRouter`. You can read about the details
[here](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux).