react-router 3.2.2 → 3.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import PropTypes from 'prop-types';
2
3
 
3
4
  // Works around issues with context updates failing to propagate.
@@ -14,15 +15,17 @@ function makeContextName(name) {
14
15
  return '@@contextSubscriber/' + name;
15
16
  }
16
17
 
18
+ var prefixUnsafeLifecycleMethods = typeof React.forwardRef !== 'undefined';
19
+
17
20
  export function ContextProvider(name) {
18
- var _childContextTypes, _ref2;
21
+ var _childContextTypes, _config;
19
22
 
20
23
  var contextName = makeContextName(name);
21
24
  var listenersKey = contextName + '/listeners';
22
25
  var eventIndexKey = contextName + '/eventIndex';
23
26
  var subscribeKey = contextName + '/subscribe';
24
27
 
25
- return _ref2 = {
28
+ var config = (_config = {
26
29
  childContextTypes: (_childContextTypes = {}, _childContextTypes[contextName] = contextProviderShape.isRequired, _childContextTypes),
27
30
 
28
31
  getChildContext: function getChildContext() {
@@ -33,10 +36,16 @@ export function ContextProvider(name) {
33
36
  subscribe: this[subscribeKey]
34
37
  }, _ref;
35
38
  },
39
+
40
+
41
+ // this method will be updated to UNSAFE_componentWillMount below for React versions >= 16.3
36
42
  componentWillMount: function componentWillMount() {
37
43
  this[listenersKey] = [];
38
44
  this[eventIndexKey] = 0;
39
45
  },
46
+
47
+
48
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
40
49
  componentWillReceiveProps: function componentWillReceiveProps() {
41
50
  this[eventIndexKey]++;
42
51
  },
@@ -47,7 +56,7 @@ export function ContextProvider(name) {
47
56
  return listener(_this[eventIndexKey]);
48
57
  });
49
58
  }
50
- }, _ref2[subscribeKey] = function (listener) {
59
+ }, _config[subscribeKey] = function (listener) {
51
60
  var _this2 = this;
52
61
 
53
62
  // No need to immediately call listener here.
@@ -58,28 +67,36 @@ export function ContextProvider(name) {
58
67
  return item !== listener;
59
68
  });
60
69
  };
61
- }, _ref2;
70
+ }, _config);
71
+
72
+ if (prefixUnsafeLifecycleMethods) {
73
+ config.UNSAFE_componentWillMount = config.componentWillMount;
74
+ config.UNSAFE_componentWillReceiveProps = config.componentWillReceiveProps;
75
+ delete config.componentWillMount;
76
+ delete config.componentWillReceiveProps;
77
+ }
78
+ return config;
62
79
  }
63
80
 
64
81
  export function ContextSubscriber(name) {
65
- var _contextTypes, _ref4;
82
+ var _contextTypes, _config2;
66
83
 
67
84
  var contextName = makeContextName(name);
68
85
  var lastRenderedEventIndexKey = contextName + '/lastRenderedEventIndex';
69
86
  var handleContextUpdateKey = contextName + '/handleContextUpdate';
70
87
  var unsubscribeKey = contextName + '/unsubscribe';
71
88
 
72
- return _ref4 = {
89
+ var config = (_config2 = {
73
90
  contextTypes: (_contextTypes = {}, _contextTypes[contextName] = contextProviderShape, _contextTypes),
74
91
 
75
92
  getInitialState: function getInitialState() {
76
- var _ref3;
93
+ var _ref2;
77
94
 
78
95
  if (!this.context[contextName]) {
79
96
  return {};
80
97
  }
81
98
 
82
- return _ref3 = {}, _ref3[lastRenderedEventIndexKey] = this.context[contextName].eventIndex, _ref3;
99
+ return _ref2 = {}, _ref2[lastRenderedEventIndexKey] = this.context[contextName].eventIndex, _ref2;
83
100
  },
84
101
  componentDidMount: function componentDidMount() {
85
102
  if (!this.context[contextName]) {
@@ -88,6 +105,9 @@ export function ContextSubscriber(name) {
88
105
 
89
106
  this[unsubscribeKey] = this.context[contextName].subscribe(this[handleContextUpdateKey]);
90
107
  },
108
+
109
+
110
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
91
111
  componentWillReceiveProps: function componentWillReceiveProps() {
92
112
  var _setState;
93
113
 
@@ -105,11 +125,17 @@ export function ContextSubscriber(name) {
105
125
  this[unsubscribeKey]();
106
126
  this[unsubscribeKey] = null;
107
127
  }
108
- }, _ref4[handleContextUpdateKey] = function (eventIndex) {
128
+ }, _config2[handleContextUpdateKey] = function (eventIndex) {
109
129
  if (eventIndex !== this.state[lastRenderedEventIndexKey]) {
110
130
  var _setState2;
111
131
 
112
132
  this.setState((_setState2 = {}, _setState2[lastRenderedEventIndexKey] = eventIndex, _setState2));
113
133
  }
114
- }, _ref4;
134
+ }, _config2);
135
+
136
+ if (prefixUnsafeLifecycleMethods) {
137
+ config.UNSAFE_componentWillReceiveProps = config.componentWillReceiveProps;
138
+ delete config.componentWillReceiveProps;
139
+ }
140
+ return config;
115
141
  }
package/es/Link.js CHANGED
@@ -4,7 +4,7 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in ob
4
4
 
5
5
  import React from 'react';
6
6
  import createReactClass from 'create-react-class';
7
- import { bool, object, string, func, oneOfType } from 'prop-types';
7
+ import { bool, object, string, func, oneOfType, shape, elementType } from 'prop-types';
8
8
  import invariant from 'invariant';
9
9
  import { routerShape } from './PropTypes';
10
10
  import { ContextSubscriber } from './ContextUtils';
@@ -57,7 +57,7 @@ var Link = createReactClass({
57
57
  onlyActiveOnIndex: bool.isRequired,
58
58
  onClick: func,
59
59
  target: string,
60
- innerRef: oneOfType([string, func])
60
+ innerRef: oneOfType([string, func, shape({ current: elementType })])
61
61
  },
62
62
 
63
63
  getDefaultProps: function getDefaultProps() {
package/es/Router.js CHANGED
@@ -25,13 +25,16 @@ var propTypes = {
25
25
 
26
26
  // PRIVATE: For client-side rehydration of server match.
27
27
  matchContext: object
28
+ };
28
29
 
29
- /**
30
- * A <Router> is a high-level API for automatically setting up
31
- * a router that renders a <RouterContext> with all the props
32
- * it needs each time the URL changes.
33
- */
34
- };var Router = createReactClass({
30
+ var prefixUnsafeLifecycleMethods = typeof React.forwardRef !== 'undefined';
31
+
32
+ /**
33
+ * A <Router> is a high-level API for automatically setting up
34
+ * a router that renders a <RouterContext> with all the props
35
+ * it needs each time the URL changes.
36
+ */
37
+ var Router = createReactClass({
35
38
  displayName: 'Router',
36
39
 
37
40
  propTypes: propTypes,
@@ -87,6 +90,9 @@ var propTypes = {
87
90
 
88
91
  return _createTransitionManager(history, createRoutes(routes || children));
89
92
  },
93
+
94
+
95
+ // this method will be updated to UNSAFE_componentWillMount below for React versions >= 16.3
90
96
  componentWillMount: function componentWillMount() {
91
97
  var _this = this;
92
98
 
@@ -106,6 +112,7 @@ var propTypes = {
106
112
  },
107
113
 
108
114
 
115
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
109
116
  /* istanbul ignore next: sanity check */
110
117
  componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
111
118
  process.env.NODE_ENV !== 'production' ? warning(nextProps.history === this.props.history, 'You cannot change <Router history>; it will be ignored') : void 0;
@@ -146,4 +153,11 @@ var propTypes = {
146
153
  }
147
154
  });
148
155
 
156
+ if (prefixUnsafeLifecycleMethods) {
157
+ Router.prototype.UNSAFE_componentWillReceiveProps = Router.prototype.componentWillReceiveProps;
158
+ Router.prototype.UNSAFE_componentWillMount = Router.prototype.componentWillMount;
159
+ delete Router.prototype.componentWillReceiveProps;
160
+ delete Router.prototype.componentWillMount;
161
+ }
162
+
149
163
  export default Router;
@@ -4,6 +4,10 @@ exports.__esModule = true;
4
4
  exports.ContextProvider = ContextProvider;
5
5
  exports.ContextSubscriber = ContextSubscriber;
6
6
 
7
+ var _react = require('react');
8
+
9
+ var _react2 = _interopRequireDefault(_react);
10
+
7
11
  var _propTypes = require('prop-types');
8
12
 
9
13
  var _propTypes2 = _interopRequireDefault(_propTypes);
@@ -24,15 +28,17 @@ function makeContextName(name) {
24
28
  return '@@contextSubscriber/' + name;
25
29
  }
26
30
 
31
+ var prefixUnsafeLifecycleMethods = typeof _react2.default.forwardRef !== 'undefined';
32
+
27
33
  function ContextProvider(name) {
28
- var _childContextTypes, _ref2;
34
+ var _childContextTypes, _config;
29
35
 
30
36
  var contextName = makeContextName(name);
31
37
  var listenersKey = contextName + '/listeners';
32
38
  var eventIndexKey = contextName + '/eventIndex';
33
39
  var subscribeKey = contextName + '/subscribe';
34
40
 
35
- return _ref2 = {
41
+ var config = (_config = {
36
42
  childContextTypes: (_childContextTypes = {}, _childContextTypes[contextName] = contextProviderShape.isRequired, _childContextTypes),
37
43
 
38
44
  getChildContext: function getChildContext() {
@@ -43,10 +49,16 @@ function ContextProvider(name) {
43
49
  subscribe: this[subscribeKey]
44
50
  }, _ref;
45
51
  },
52
+
53
+
54
+ // this method will be updated to UNSAFE_componentWillMount below for React versions >= 16.3
46
55
  componentWillMount: function componentWillMount() {
47
56
  this[listenersKey] = [];
48
57
  this[eventIndexKey] = 0;
49
58
  },
59
+
60
+
61
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
50
62
  componentWillReceiveProps: function componentWillReceiveProps() {
51
63
  this[eventIndexKey]++;
52
64
  },
@@ -57,7 +69,7 @@ function ContextProvider(name) {
57
69
  return listener(_this[eventIndexKey]);
58
70
  });
59
71
  }
60
- }, _ref2[subscribeKey] = function (listener) {
72
+ }, _config[subscribeKey] = function (listener) {
61
73
  var _this2 = this;
62
74
 
63
75
  // No need to immediately call listener here.
@@ -68,28 +80,36 @@ function ContextProvider(name) {
68
80
  return item !== listener;
69
81
  });
70
82
  };
71
- }, _ref2;
83
+ }, _config);
84
+
85
+ if (prefixUnsafeLifecycleMethods) {
86
+ config.UNSAFE_componentWillMount = config.componentWillMount;
87
+ config.UNSAFE_componentWillReceiveProps = config.componentWillReceiveProps;
88
+ delete config.componentWillMount;
89
+ delete config.componentWillReceiveProps;
90
+ }
91
+ return config;
72
92
  }
73
93
 
74
94
  function ContextSubscriber(name) {
75
- var _contextTypes, _ref4;
95
+ var _contextTypes, _config2;
76
96
 
77
97
  var contextName = makeContextName(name);
78
98
  var lastRenderedEventIndexKey = contextName + '/lastRenderedEventIndex';
79
99
  var handleContextUpdateKey = contextName + '/handleContextUpdate';
80
100
  var unsubscribeKey = contextName + '/unsubscribe';
81
101
 
82
- return _ref4 = {
102
+ var config = (_config2 = {
83
103
  contextTypes: (_contextTypes = {}, _contextTypes[contextName] = contextProviderShape, _contextTypes),
84
104
 
85
105
  getInitialState: function getInitialState() {
86
- var _ref3;
106
+ var _ref2;
87
107
 
88
108
  if (!this.context[contextName]) {
89
109
  return {};
90
110
  }
91
111
 
92
- return _ref3 = {}, _ref3[lastRenderedEventIndexKey] = this.context[contextName].eventIndex, _ref3;
112
+ return _ref2 = {}, _ref2[lastRenderedEventIndexKey] = this.context[contextName].eventIndex, _ref2;
93
113
  },
94
114
  componentDidMount: function componentDidMount() {
95
115
  if (!this.context[contextName]) {
@@ -98,6 +118,9 @@ function ContextSubscriber(name) {
98
118
 
99
119
  this[unsubscribeKey] = this.context[contextName].subscribe(this[handleContextUpdateKey]);
100
120
  },
121
+
122
+
123
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
101
124
  componentWillReceiveProps: function componentWillReceiveProps() {
102
125
  var _setState;
103
126
 
@@ -115,11 +138,17 @@ function ContextSubscriber(name) {
115
138
  this[unsubscribeKey]();
116
139
  this[unsubscribeKey] = null;
117
140
  }
118
- }, _ref4[handleContextUpdateKey] = function (eventIndex) {
141
+ }, _config2[handleContextUpdateKey] = function (eventIndex) {
119
142
  if (eventIndex !== this.state[lastRenderedEventIndexKey]) {
120
143
  var _setState2;
121
144
 
122
145
  this.setState((_setState2 = {}, _setState2[lastRenderedEventIndexKey] = eventIndex, _setState2));
123
146
  }
124
- }, _ref4;
147
+ }, _config2);
148
+
149
+ if (prefixUnsafeLifecycleMethods) {
150
+ config.UNSAFE_componentWillReceiveProps = config.componentWillReceiveProps;
151
+ delete config.componentWillReceiveProps;
152
+ }
153
+ return config;
125
154
  }
package/lib/Link.js CHANGED
@@ -74,7 +74,7 @@ var Link = (0, _createReactClass2.default)({
74
74
  onlyActiveOnIndex: _propTypes.bool.isRequired,
75
75
  onClick: _propTypes.func,
76
76
  target: _propTypes.string,
77
- innerRef: (0, _propTypes.oneOfType)([_propTypes.string, _propTypes.func])
77
+ innerRef: (0, _propTypes.oneOfType)([_propTypes.string, _propTypes.func, (0, _propTypes.shape)({ current: _propTypes.elementType })])
78
78
  },
79
79
 
80
80
  getDefaultProps: function getDefaultProps() {
package/lib/Router.js CHANGED
@@ -51,13 +51,16 @@ var propTypes = {
51
51
 
52
52
  // PRIVATE: For client-side rehydration of server match.
53
53
  matchContext: _propTypes.object
54
+ };
54
55
 
55
- /**
56
- * A <Router> is a high-level API for automatically setting up
57
- * a router that renders a <RouterContext> with all the props
58
- * it needs each time the URL changes.
59
- */
60
- };var Router = (0, _createReactClass2.default)({
56
+ var prefixUnsafeLifecycleMethods = typeof _react2.default.forwardRef !== 'undefined';
57
+
58
+ /**
59
+ * A <Router> is a high-level API for automatically setting up
60
+ * a router that renders a <RouterContext> with all the props
61
+ * it needs each time the URL changes.
62
+ */
63
+ var Router = (0, _createReactClass2.default)({
61
64
  displayName: 'Router',
62
65
 
63
66
  propTypes: propTypes,
@@ -113,6 +116,9 @@ var propTypes = {
113
116
 
114
117
  return (0, _createTransitionManager3.default)(history, (0, _RouteUtils.createRoutes)(routes || children));
115
118
  },
119
+
120
+
121
+ // this method will be updated to UNSAFE_componentWillMount below for React versions >= 16.3
116
122
  componentWillMount: function componentWillMount() {
117
123
  var _this = this;
118
124
 
@@ -132,6 +138,7 @@ var propTypes = {
132
138
  },
133
139
 
134
140
 
141
+ // this method will be updated to UNSAFE_componentWillReceiveProps below for React versions >= 16.3
135
142
  /* istanbul ignore next: sanity check */
136
143
  componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
137
144
  process.env.NODE_ENV !== 'production' ? (0, _routerWarning2.default)(nextProps.history === this.props.history, 'You cannot change <Router history>; it will be ignored') : void 0;
@@ -172,5 +179,12 @@ var propTypes = {
172
179
  }
173
180
  });
174
181
 
182
+ if (prefixUnsafeLifecycleMethods) {
183
+ Router.prototype.UNSAFE_componentWillReceiveProps = Router.prototype.componentWillReceiveProps;
184
+ Router.prototype.UNSAFE_componentWillMount = Router.prototype.componentWillMount;
185
+ delete Router.prototype.componentWillReceiveProps;
186
+ delete Router.prototype.componentWillMount;
187
+ }
188
+
175
189
  exports.default = Router;
176
190
  module.exports = exports['default'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "3.2.2",
3
+ "version": "3.2.6",
4
4
  "description": "A complete routing library for React",
5
5
  "files": [
6
6
  "*.md",
@@ -22,6 +22,7 @@
22
22
  "build-umd": "cross-env NODE_ENV=development webpack modules/index.js umd/ReactRouter.js",
23
23
  "build-min": "cross-env NODE_ENV=production webpack -p modules/index.js umd/ReactRouter.min.js",
24
24
  "lint": "eslint examples modules scripts tools *.js",
25
+ "prepublishOnly": "node ./scripts/build.js",
25
26
  "start": "node examples/server.js",
26
27
  "test": "npm run lint && npm run test-node && npm run test-browser",
27
28
  "test-browser": "cross-env NODE_ENV=test karma start",
@@ -35,11 +36,11 @@
35
36
  "dependencies": {
36
37
  "create-react-class": "^15.5.1",
37
38
  "history": "^3.0.0",
38
- "hoist-non-react-statics": "^2.3.1",
39
+ "hoist-non-react-statics": "^3.3.2",
39
40
  "invariant": "^2.2.1",
40
41
  "loose-envify": "^1.2.0",
41
42
  "prop-types": "^15.7.2",
42
- "react-is": "^16.8.6",
43
+ "react-is": "^16.13.0",
43
44
  "warning": "^3.0.0"
44
45
  },
45
46
  "peerDependencies": {
@@ -80,9 +81,9 @@
80
81
  "mocha": "^5.0.4",
81
82
  "pretty-bytes": "^4.0.2",
82
83
  "qs": "^6.2.1",
83
- "react": "^16.8.6",
84
+ "react": "^16.9.0",
84
85
  "react-addons-css-transition-group": "^15.6.0",
85
- "react-dom": "^16.8.6",
86
+ "react-dom": "^16.9.0",
86
87
  "rimraf": "^2.5.4",
87
88
  "style-loader": "^0.16.1",
88
89
  "webpack": "^1.13.1",