@@ -26,7 +26,7 @@ npm install redux-simple-router
26
26
27
27
[ redux-router] ( https://github.com/rackt/redux-router ) is another
28
28
project which solves the same problem. However, it's far more complex.
29
- Just looks look at this code: the whole thing is only 68 lines of JS.
29
+ Just look at this code: the whole thing is only 68 lines of JS.
30
30
redux-router is much bigger and more complex.
31
31
32
32
That said, redux-router is a fine project and has features this
@@ -48,7 +48,7 @@ It should be very future-proof with any versions of either libraries.
48
48
49
49
## How to Use
50
50
51
- The idea of this libray is to use react-router's functionality exactly
51
+ The idea of this library is to use react-router's functionality exactly
52
52
like its documentation tells you to. You can access all of its APIs in
53
53
routing components. Additionally, you can use redux like you normally
54
54
would, with a single app state and "connected" components. It's even
@@ -61,16 +61,17 @@ it, and also change it with an action.
61
61
Here's some code:
62
62
63
63
``` js
64
- const { createStore } = require (' redux' );
64
+ const { createStore , combineReducers } = require (' redux' );
65
65
const { Provider } = require (' react-redux' );
66
66
const { Router , Route } = require (' react-router' );
67
67
const createBrowserHistory = require (' history/lib/createBrowserHistory' );
68
68
const { syncReduxAndRouter , routeReducer } = require (' redux-simple-routing' );
69
69
const reducers = require (' <project-path>/reducers' );
70
70
71
- const store = createStore (Object .assign ({}, reducers, {
71
+ const reducer = combineReducers (Object .assign ({}, reducers, {
72
72
routing: routeReducer
73
- });
73
+ }));
74
+ const store = createStore (reducer);
74
75
const history = createBrowserHistory ();
75
76
76
77
syncReduxAndRouter (history, store);
@@ -121,7 +122,7 @@ function update(state, action) {
121
122
### ` syncReduxAndRouter(history, store) `
122
123
123
124
Call this with a react-router and a redux store instance to install
124
- hooks that always keep both of them in sync. When one changes, so with
125
+ hooks that always keep both of them in sync. When one changes, so will
125
126
the other.
126
127
127
128
### ` routeReducer `
0 commit comments