simred-react-router
React Router bindings to Simred state manager.
If you do not know what Simred is, checkout the project's GitHub page
It exposes all functions from the history
package:
- createBrowserHistory
- createMemoryHistory
- ...
And two more functions:
createRouterReducer(history: History): Reducer
Creates a Simred reducer for the router from the history (BrowserHistoy
, MemoryHistory
, or HashHistory
)
`createConnectedRouter(routerReducerKey: string): Router
Creates a Router
Component connected to the Simred store.
The routerReducerKey
argument is the key in the root reducer holding the router reducer.
Example:
const history = createMemoryHistory const rootReducer = // "router" is the routerReducerKey to pass to createConnectedRouter router: const ConnectedRouter =
OR
const history = createMemoryHistory const rootReducer = // "myGreatRouter" is the routerReducerKey to pass to createConnectedRouter myGreatRouter: const ConnectedRouter =
Installation
$ npm install --save simred-react-router
Usage
// The same history object needs to be passed to both the reducer and the componentconst history = // Add a RouterReducer to Simred's root reducerconst rootReducer = router: const store = Simred// Create a Router connected to Simred// Passing the key of the RouterReducer in the rootReducer const Router = // the ConnectedRouter is a HOC around react-router's own component// and works the same
License
MIT © Gaël PHILIPPE