react-router-redux
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -1,5 +0,13 @@ | ||
## [HEAD](https://github.com/rackt/react-router-redux/compare/2.1.0...master) | ||
## [HEAD](https://github.com/rackt/react-router-redux/compare/3.0.0...master) | ||
- Nothing yet! | ||
## [3.0.0](https://github.com/rackt/react-router-redux/compare/2.1.0...3.0.0) | ||
Techincally, 2.1.0 broke semver. The appropriate @timdorr's have been flogged. So, we're bumping the major version to catch up. | ||
- Fixed Resets in Redux Dev Tools. [3ae8110f](https://github.com/rackt/react-router-redux/commit/3ae8110f) | ||
- Ensure the initialState is set properly. [a00acfd4](https://github.com/rackt/react-router-redux/commit/a00acfd4) | ||
- Support any number of args on action creators [524898b5](https://github.com/rackt/react-router-redux/commit/524898b5) | ||
## [2.1.0](https://github.com/rackt/react-router-redux/compare/2.0.4...2.1.0) | ||
@@ -6,0 +14,0 @@ |
@@ -10,2 +10,5 @@ 'use strict'; | ||
exports.syncHistory = syncHistory; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
// Constants | ||
@@ -21,6 +24,10 @@ | ||
function transition(method) { | ||
return function (arg) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return { | ||
type: TRANSITION, | ||
payload: { method: method, arg: arg } | ||
payload: { method: method, args: args } | ||
}; | ||
@@ -73,2 +80,6 @@ }; | ||
history.listen(function (location) { | ||
initialState.location = location; | ||
})(); | ||
function middleware(store) { | ||
@@ -95,5 +106,5 @@ unsubscribeHistory = history.listen(function (location) { | ||
var method = _action$payload.method; | ||
var arg = _action$payload.arg; | ||
var args = _action$payload.args; | ||
history[method](arg); | ||
history[method].apply(history, _toConsumableArray(args)); | ||
}; | ||
@@ -117,4 +128,4 @@ }; | ||
// appropriately. | ||
if (!location) { | ||
history.transitionTo(initialLocation); | ||
if (location.key === initialLocation.key) { | ||
history.replace(initialLocation); | ||
return; | ||
@@ -121,0 +132,0 @@ } |
{ | ||
"name": "react-router-redux", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Ruthlessly simple bindings to keep react-router and redux in sync", | ||
@@ -14,3 +14,4 @@ "main": "lib/index", | ||
"authors": [ | ||
"James Long" | ||
"James Long", | ||
"Tim Dorr" | ||
], | ||
@@ -17,0 +18,0 @@ "license": "MIT", |
@@ -7,2 +7,4 @@ # react-router-redux | ||
_Formerly known as redux-simple-router_ | ||
[Redux](https://github.com/rackt/redux) is awesome. [React Router](https://github.com/rackt/react-router) is cool. The problem is that react-router manages an important piece of your application state: the URL. If you are using redux, you want your app state to fully represent your UI; if you snapshotted the app state, you should be able to load it up later and see the same thing. | ||
@@ -107,3 +109,16 @@ | ||
``` | ||
**But how do I access router props in a Container component?** | ||
react-router [injects route information via a child component's props](https://github.com/rackt/react-router/blob/latest/docs/Introduction.md#getting-url-parameters). This makes accessing them from a simple component easy. When using a react-redux Container to connect simple components to the store state and dispatch you can access these injected route information from the [2nd argument of `mapStateToProps`](https://github.com/rackt/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) as follows: | ||
```js | ||
function mapStateToProps(state, ownProps) { | ||
return { | ||
id: ownProps.params.id, | ||
filter: ownProps.location.query.filter | ||
}; | ||
} | ||
``` | ||
### Examples | ||
@@ -110,0 +125,0 @@ |
@@ -9,5 +9,5 @@ // Constants | ||
function transition(method) { | ||
return arg => ({ | ||
return (...args) => ({ | ||
type: TRANSITION, | ||
payload: { method, arg } | ||
payload: { method, args } | ||
}) | ||
@@ -51,2 +51,4 @@ } | ||
history.listen(location => { initialState.location = location })() | ||
function middleware(store) { | ||
@@ -70,4 +72,4 @@ unsubscribeHistory = history.listen(location => { | ||
const { payload: { method, arg } } = action | ||
history[method](arg) | ||
const { payload: { method, args } } = action | ||
history[method](...args) | ||
} | ||
@@ -87,4 +89,4 @@ } | ||
// appropriately. | ||
if (!location) { | ||
history.transitionTo(initialLocation) | ||
if (location.key === initialLocation.key) { | ||
history.replace(initialLocation) | ||
return | ||
@@ -91,0 +93,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24434
204
180