Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hoppula/react-router-redux-params
Adds react-router params to redux in addition to location
https://github.com/hoppula/react-router-redux-params
react react-router redux
Last synced: about 1 month ago
JSON representation
Adds react-router params to redux in addition to location
- Host: GitHub
- URL: https://github.com/hoppula/react-router-redux-params
- Owner: hoppula
- Created: 2016-03-08T15:33:13.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-30T22:11:56.000Z (over 7 years ago)
- Last Synced: 2024-09-21T22:50:58.180Z (3 months ago)
- Topics: react, react-router, redux
- Language: JavaScript
- Size: 10.7 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-router-redux-params
Provides extra methods for [react-router-redux](https://github.com/reactjs/react-router-redux) which store [react-router](https://github.com/reactjs/react-router) route params in addition to history location object.
You won't need this if you're only accessing route params inside your components, react-router already provides params as a prop. This is meant for usage outside component tree, for example with [refire](https://github.com/hoppula/refire).
**NOTE** This hasn't been tested with [redux-devtools](https://github.com/gaearon/redux-devtools), breakage might ensue.
## Usage
```js
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { Router, Route, browserHistory } from 'react-router'
import { syncHistory, syncParams, routeParamsReducer } from 'react-router-redux-params'
import reducers from '/reducers'const routes = (
)const reducer = combineReducers(Object.assign({}, reducers, {
routing: routeParamsReducer
}))// Sync dispatched route actions to the history
const createStoreWithMiddleware = applyMiddleware(
syncHistory(browserHistory)
)(createStore)const store = createStoreWithMiddleware(reducer)
// syncParams also accepts custom action creator as fourth parameter, see src/index.js for more info
syncParams(store, routes, browserHistory)ReactDOM.render(
{routes}
,
document.getElementById('mount')
)
```## License
MIT