react-router-redux
Advanced tools
Comparing version 5.0.0-alpha.6 to 5.0.0-alpha.7
@@ -51,5 +51,9 @@ 'use strict'; | ||
this.store = propsStore || this.context.store; | ||
this.handleLocationChange(history.location); | ||
}; | ||
ConnectedRouter.prototype.componentDidMount = function componentDidMount() { | ||
var history = this.props.history; | ||
this.unsubscribeFromHistory = history.listen(this.handleLocationChange); | ||
this.handleLocationChange(history.location); | ||
}; | ||
@@ -56,0 +60,0 @@ |
@@ -39,5 +39,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
this.store = propsStore || this.context.store; | ||
this.handleLocationChange(history.location); | ||
}; | ||
ConnectedRouter.prototype.componentDidMount = function componentDidMount() { | ||
var history = this.props.history; | ||
this.unsubscribeFromHistory = history.listen(this.handleLocationChange); | ||
this.handleLocationChange(history.location); | ||
}; | ||
@@ -44,0 +48,0 @@ |
import _ConnectedRouter from './ConnectedRouter'; | ||
export { _ConnectedRouter as ConnectedRouter }; | ||
export { getLocation, createMatchSelector } from './selectors'; | ||
export { LOCATION_CHANGE, routerReducer } from './reducer'; | ||
@@ -5,0 +6,0 @@ export { CALL_HISTORY_METHOD, push, replace, go, goBack, goForward, routerActions } from './actions'; |
@@ -11,11 +11,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
location: null | ||
}; | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
export function routerReducer() { | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
};export function routerReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -22,0 +21,0 @@ |
17
index.js
'use strict'; | ||
exports.__esModule = true; | ||
exports.routerMiddleware = exports.routerActions = exports.goForward = exports.goBack = exports.go = exports.replace = exports.push = exports.CALL_HISTORY_METHOD = exports.routerReducer = exports.LOCATION_CHANGE = exports.ConnectedRouter = undefined; | ||
exports.routerMiddleware = exports.routerActions = exports.goForward = exports.goBack = exports.go = exports.replace = exports.push = exports.CALL_HISTORY_METHOD = exports.routerReducer = exports.LOCATION_CHANGE = exports.createMatchSelector = exports.getLocation = exports.ConnectedRouter = undefined; | ||
var _selectors = require('./selectors'); | ||
Object.defineProperty(exports, 'getLocation', { | ||
enumerable: true, | ||
get: function get() { | ||
return _selectors.getLocation; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'createMatchSelector', { | ||
enumerable: true, | ||
get: function get() { | ||
return _selectors.createMatchSelector; | ||
} | ||
}); | ||
var _reducer = require('./reducer'); | ||
@@ -7,0 +22,0 @@ |
{ | ||
"name": "react-router-redux", | ||
"version": "5.0.0-alpha.6", | ||
"version": "5.0.0-alpha.7", | ||
"description": "Redux bindings for React Router", | ||
@@ -12,8 +12,7 @@ "repository": "ReactTraining/react-router", | ||
"ConnectedRouter.js", | ||
"reducer.js", | ||
"middleware.js", | ||
"actions.js", | ||
"es", | ||
"index.js", | ||
"README.md", | ||
"es", | ||
"middleware.js", | ||
"reducer.js", | ||
"umd" | ||
@@ -25,3 +24,3 @@ ], | ||
"build": "node ./tools/build.js", | ||
"prepublish": "node ./tools/build.js", | ||
"prepublishOnly": "node ./tools/build.js", | ||
"watch": "babel ./modules -d . --ignore __tests__ --watch", | ||
@@ -33,34 +32,33 @@ "clean": "git clean -fdX .", | ||
"peerDependencies": { | ||
"react": "^15" | ||
"react": ">=15" | ||
}, | ||
"dependencies": { | ||
"history": "^4.5.1", | ||
"prop-types": "^15.5.4", | ||
"react-router": "^4.1.1" | ||
"history": "^4.7.2", | ||
"prop-types": "^15.6.0", | ||
"react-router": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.14.0", | ||
"babel-core": "^6.14.0", | ||
"babel-eslint": "^7.1.1", | ||
"babel-jest": "^19.0.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.3.2", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.0.1", | ||
"babel-jest": "^21.2.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.10", | ||
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-1": "^6.5.0", | ||
"eslint": "^3.5.0", | ||
"eslint": "^4.9.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-react": "^6.3.0", | ||
"gzip-size": "^3.0.0", | ||
"in-publish": "^2.0.0", | ||
"jest": "^19.0.2", | ||
"eslint-plugin-react": "^7.4.0", | ||
"gzip-size": "^4.0.0", | ||
"jest": "^21.2.1", | ||
"pretty-bytes": "^4.0.2", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"react-redux": "^5.0.3", | ||
"react-test-renderer": "^15.3.2", | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0", | ||
"react-redux": "^5.0.6", | ||
"react-test-renderer": "^16.0.0", | ||
"redux": "^3.6.0", | ||
"rollup": "^0.41.4", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-uglify": "^1.0.1" | ||
"rollup": "^0.50.0", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
} | ||
} |
# react-router-redux | ||
[![npm version](https://img.shields.io/npm/v/react-router-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-router-redux) [![npm downloads](https://img.shields.io/npm/dm/react-router-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-router-redux) [![build status](https://img.shields.io/travis/reactjs/react-router-redux/master.svg?style=flat-square)](https://travis-ci.org/reactjs/react-router-redux) | ||
[![npm version](https://img.shields.io/npm/v/react-router-redux/next.svg?style=flat-square)](https://www.npmjs.com/package/react-router-redux) [![npm downloads](https://img.shields.io/npm/dm/react-router-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-router-redux) [![build status](https://img.shields.io/travis/reactjs/react-router-redux/master.svg?style=flat-square)](https://travis-ci.org/reactjs/react-router-redux) | ||
@@ -13,3 +13,8 @@ > **Keep your state in sync with your router** :sparkles: | ||
- (issue describing a different approach to what we've seen previously coming soon) | ||
## Versions | ||
This (react-router-redux 5.x) is the version of react-router-redux for use with react-router 4.x. | ||
Users of react-router 2.x and 3.x want to use react-router-redux found at [the legacy repository](https://github.com/reactjs/react-router-redux). | ||
## Installation | ||
@@ -19,2 +24,3 @@ | ||
npm install --save react-router-redux@next | ||
npm install --save history | ||
``` | ||
@@ -21,0 +27,0 @@ |
@@ -16,11 +16,10 @@ 'use strict'; | ||
location: null | ||
}; | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
function routerReducer() { | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
};function routerReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -27,0 +26,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('prop-types'), require('react-router')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'prop-types', 'react-router'], factory) : | ||
(factory((global.ReactRouterRedux = global.ReactRouterRedux || {}),global.React,global.PropTypes,global.ReactRouter)); | ||
(factory((global.ReactRouterRedux = {}),global.React,global.PropTypes,global.ReactRouter)); | ||
}(this, (function (exports,React,PropTypes,reactRouter) { 'use strict'; | ||
var React__default = 'default' in React ? React['default'] : React; | ||
PropTypes = 'default' in PropTypes ? PropTypes['default'] : PropTypes; | ||
PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes; | ||
@@ -20,11 +20,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
location: null | ||
}; | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
function routerReducer() { | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
};function routerReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -75,5 +74,9 @@ | ||
this.store = propsStore || this.context.store; | ||
this.handleLocationChange(history.location); | ||
}; | ||
ConnectedRouter.prototype.componentDidMount = function componentDidMount() { | ||
var history = this.props.history; | ||
this.unsubscribeFromHistory = history.listen(this.handleLocationChange); | ||
this.handleLocationChange(history.location); | ||
}; | ||
@@ -101,2 +104,25 @@ | ||
var getLocation = function getLocation(state) { | ||
return state.router.location; | ||
}; | ||
var createMatchSelector = function createMatchSelector(path) { | ||
var lastPathname = null; | ||
var lastMatch = null; | ||
return function (state) { | ||
var _getLocation = getLocation(state), | ||
pathname = _getLocation.pathname; | ||
if (pathname === lastPathname) { | ||
return lastMatch; | ||
} | ||
lastPathname = pathname; | ||
var match = reactRouter.matchPath(pathname, path); | ||
if (!match || !lastMatch || match.url !== lastMatch.url) { | ||
lastMatch = match; | ||
} | ||
return lastMatch; | ||
}; | ||
}; | ||
/** | ||
@@ -160,2 +186,4 @@ * This action type will be dispatched by the history actions below. | ||
exports.routerMiddleware = routerMiddleware; | ||
exports.getLocation = getLocation; | ||
exports.createMatchSelector = createMatchSelector; | ||
exports.LOCATION_CHANGE = LOCATION_CHANGE; | ||
@@ -162,0 +190,0 @@ exports.routerReducer = routerReducer; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-router"],t):t(e.ReactRouterRedux=e.ReactRouterRedux||{},e.React,e.PropTypes,e.ReactRouter)}(this,function(e,t,o,r){"use strict";function n(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:d,t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},o=t.type,r=t.payload;return o===l?f({},e,{location:r}):e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function c(e){return function(){for(var t=arguments.length,o=Array(t),r=0;t>r;r++)o[r]=arguments[r];return{type:y,payload:{method:e,args:o}}}}function p(e){return function(){return function(t){return function(o){if(o.type!==y)return t(o);var r=o.payload;e[r.method].apply(e,r.args)}}}}var s="default"in t?t["default"]:t;o="default"in o?o["default"]:o;var f=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},l="@@router/LOCATION_CHANGE",d={location:null},h=function(e){function t(){var o,r,n;i(this,t);for(var u=arguments.length,c=Array(u),p=0;u>p;p++)c[p]=arguments[p];return o=r=a(this,e.call.apply(e,[this].concat(c))),r.handleLocationChange=function(e){r.store.dispatch({type:l,payload:e})},n=o,a(r,n)}return u(t,e),t.prototype.componentWillMount=function(){var e=this.props,t=e.store,o=e.history;this.store=t||this.context.store,this.unsubscribeFromHistory=o.listen(this.handleLocationChange),this.handleLocationChange(o.location)},t.prototype.componentWillUnmount=function(){this.unsubscribeFromHistory&&this.unsubscribeFromHistory()},t.prototype.render=function(){return s.createElement(r.Router,this.props)},t}(t.Component);h.propTypes={store:o.object,history:o.object,children:o.node},h.contextTypes={store:o.object};var y="@@router/CALL_HISTORY_METHOD",b=c("push"),g=c("replace"),O=c("go"),R=c("goBack"),m=c("goForward"),v={push:b,replace:g,go:O,goBack:R,goForward:m};e.ConnectedRouter=h,e.routerMiddleware=p,e.LOCATION_CHANGE=l,e.routerReducer=n,e.CALL_HISTORY_METHOD=y,e.push=b,e.replace=g,e.go=O,e.goBack=R,e.goForward=m,e.routerActions=v,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("prop-types"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-router"],e):e(t.ReactRouterRedux={},t.React,t.PropTypes,t.ReactRouter)}(this,function(t,e,r,o){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t){return function(){for(var e=arguments.length,r=Array(e),o=0;e>o;o++)r[o]=arguments[o];return{type:y,payload:{method:t,args:r}}}}var c="default"in e?e.default:e;r=r&&r.hasOwnProperty("default")?r.default:r;var p=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},s="@@router/LOCATION_CHANGE",l={location:null},f=function(t){function e(){var r,o,i;n(this,e);for(var u=arguments.length,c=Array(u),p=0;u>p;p++)c[p]=arguments[p];return r=o=a(this,t.call.apply(t,[this].concat(c))),o.handleLocationChange=function(t){o.store.dispatch({type:s,payload:t})},i=r,a(o,i)}return i(e,t),e.prototype.componentWillMount=function(){var t=this.props,e=t.store,r=t.history;this.store=e||this.context.store,this.handleLocationChange(r.location)},e.prototype.componentDidMount=function(){var t=this.props.history;this.unsubscribeFromHistory=t.listen(this.handleLocationChange)},e.prototype.componentWillUnmount=function(){this.unsubscribeFromHistory&&this.unsubscribeFromHistory()},e.prototype.render=function(){return c.createElement(o.Router,this.props)},e}(e.Component);f.propTypes={store:r.object,history:r.object,children:r.node},f.contextTypes={store:r.object};var h=function(t){return t.router.location},y="@@router/CALL_HISTORY_METHOD",d=u("push"),b=u("replace"),g=u("go"),v=u("goBack"),O=u("goForward"),m={push:d,replace:b,go:g,goBack:v,goForward:O};t.ConnectedRouter=f,t.routerMiddleware=function(t){return function(){return function(e){return function(r){if(r.type!==y)return e(r);var o=r.payload,n=o.method,a=o.args;t[n].apply(t,a)}}}},t.getLocation=h,t.createMatchSelector=function(t){var e=null,r=null;return function(n){var a=h(n).pathname;if(a===e)return r;e=a;var i=o.matchPath(a,t);return i&&r&&i.url===r.url||(r=i),r}},t.LOCATION_CHANGE=s,t.routerReducer=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.type,o=e.payload;return r===s?p({},t,{location:o}):t},t.CALL_HISTORY_METHOD=y,t.push=d,t.replace=b,t.go=g,t.goBack=v,t.goForward=O,t.routerActions=m,Object.defineProperty(t,"__esModule",{value:!0})}); |
29656
22
15
530
77
+ Addedreact@18.3.1(transitive)
- Removedasap@2.0.6(transitive)
- Removedcore-js@1.2.7(transitive)
- Removedcreate-react-class@15.7.0(transitive)
- Removedencoding@0.1.13(transitive)
- Removedfbjs@0.8.18(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedpromise@7.3.1(transitive)
- Removedreact@15.7.0(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedua-parser-js@0.7.38(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)
Updatedhistory@^4.7.2
Updatedprop-types@^15.6.0
Updatedreact-router@^4.2.0