react-router 3.2.1 → 3.2.5

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.
package/docs/API.md CHANGED
@@ -135,6 +135,9 @@ A custom handler for the click event. Works just like a handler on an `<a>` tag
135
135
  ##### `onlyActiveOnIndex`
136
136
  If `true`, the `<Link>` will only be active when the current route exactly matches the linked route.
137
137
 
138
+ ##### `innerRef`
139
+ Allows access to the underlying `ref` of the component.
140
+
138
141
  ##### *others*
139
142
  You can also pass props you'd like to be on the `<a>` such as a `title`, `id`, `className`, etc.
140
143
 
@@ -153,6 +156,11 @@ Given a route like `<Route path="/users/:userId" />`:
153
156
 
154
157
  // change style when link is active
155
158
  <Link to="/users" style={{color: 'white'}} activeStyle={{color: 'red'}}>Users</Link>
159
+
160
+ const refCallback = node => {
161
+ // `node` refers to the mounted DOM element or null when unmounted
162
+ }
163
+ <Link to="/" innerRef={refCallback} />
156
164
  ```
157
165
 
158
166
  ### `<IndexLink>`
@@ -338,7 +346,9 @@ class Users extends React.Component {
338
346
  ```
339
347
 
340
348
  ##### `getComponent(nextState, callback)`
341
- Same as `component` but asynchronous, useful for code-splitting.
349
+ Same as `component` but asynchronous, useful for code-splitting.
350
+
351
+ You can pass a Promise, in which case you should not use the `callback` function and instead use `resolve` like you normally would. You can also pass an async function, which is a Promise under the hood, and just `return` like normal. Any thrown exception will report an error to the router.
342
352
 
343
353
  ###### `callback` signature
344
354
  `cb(err, component)`
@@ -350,6 +360,7 @@ Same as `component` but asynchronous, useful for code-splitting.
350
360
  }} />
351
361
  ```
352
362
 
363
+
353
364
  ##### `getComponents(nextState, callback)`
354
365
  Same as `components` but asynchronous, useful for
355
366
  code-splitting.
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { func, object, arrayOf, oneOfType, element, shape, string } from 'prop-types';
1
+ import { func, object, arrayOf, oneOfType, element, shape, elementType } from 'prop-types';
2
2
 
3
3
  export function falsy(props, propName, componentName) {
4
4
  if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
@@ -13,7 +13,7 @@ export var history = shape({
13
13
  goForward: func.isRequired
14
14
  });
15
15
 
16
- export var component = oneOfType([func, string]);
16
+ export var component = elementType;
17
17
  export var components = oneOfType([component, object]);
18
18
  export var route = oneOfType([object, element]);
19
19
  export var routes = oneOfType([route, arrayOf(route)]);
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';
@@ -56,7 +56,8 @@ var Link = createReactClass({
56
56
  activeClassName: string,
57
57
  onlyActiveOnIndex: bool.isRequired,
58
58
  onClick: func,
59
- target: string
59
+ target: string,
60
+ innerRef: oneOfType([string, func, shape({ current: elementType })])
60
61
  },
61
62
 
62
63
  getDefaultProps: function getDefaultProps() {
@@ -90,7 +91,8 @@ var Link = createReactClass({
90
91
  activeClassName = _props.activeClassName,
91
92
  activeStyle = _props.activeStyle,
92
93
  onlyActiveOnIndex = _props.onlyActiveOnIndex,
93
- props = _objectWithoutProperties(_props, ['to', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex']);
94
+ innerRef = _props.innerRef,
95
+ props = _objectWithoutProperties(_props, ['to', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex', 'innerRef']);
94
96
 
95
97
  // Ignore if rendered outside the context of router to simplify unit testing.
96
98
 
@@ -101,7 +103,7 @@ var Link = createReactClass({
101
103
  if (router) {
102
104
  // If user does not specify a `to` prop, return an empty anchor tag.
103
105
  if (!to) {
104
- return React.createElement('a', props);
106
+ return React.createElement('a', _extends({}, props, { ref: innerRef }));
105
107
  }
106
108
 
107
109
  var toLocation = resolveToLocation(to, router);
@@ -122,7 +124,7 @@ var Link = createReactClass({
122
124
  }
123
125
  }
124
126
 
125
- return React.createElement('a', _extends({}, props, { onClick: this.handleClick }));
127
+ return React.createElement('a', _extends({}, props, { onClick: this.handleClick, ref: innerRef }));
126
128
  }
127
129
  });
128
130
 
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,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4
4
 
5
5
  import invariant from 'invariant';
6
6
  import React from 'react';
7
+ import { isValidElementType } from 'react-is';
7
8
  import createReactClass from 'create-react-class';
8
9
  import { array, func, object } from 'prop-types';
9
10
 
@@ -83,7 +84,9 @@ var RouterContext = createReactClass({
83
84
  }
84
85
  }
85
86
 
86
- if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object') {
87
+ // Handle components is object for { [name]: component } but not valid element
88
+ // type of react, such as React.memo, React.lazy and so on.
89
+ if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object' && !isValidElementType(components)) {
87
90
  var elements = {};
88
91
 
89
92
  for (var key in components) {
@@ -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
  }
@@ -19,7 +19,7 @@ var history = exports.history = (0, _propTypes.shape)({
19
19
  goForward: _propTypes.func.isRequired
20
20
  });
21
21
 
22
- var component = exports.component = (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.string]);
22
+ var component = exports.component = _propTypes.elementType;
23
23
  var components = exports.components = (0, _propTypes.oneOfType)([component, _propTypes.object]);
24
24
  var route = exports.route = (0, _propTypes.oneOfType)([_propTypes.object, _propTypes.element]);
25
25
  var routes = exports.routes = (0, _propTypes.oneOfType)([route, (0, _propTypes.arrayOf)(route)]);
package/lib/Link.js CHANGED
@@ -73,7 +73,8 @@ var Link = (0, _createReactClass2.default)({
73
73
  activeClassName: _propTypes.string,
74
74
  onlyActiveOnIndex: _propTypes.bool.isRequired,
75
75
  onClick: _propTypes.func,
76
- target: _propTypes.string
76
+ target: _propTypes.string,
77
+ innerRef: (0, _propTypes.oneOfType)([_propTypes.string, _propTypes.func, (0, _propTypes.shape)({ current: _propTypes.elementType })])
77
78
  },
78
79
 
79
80
  getDefaultProps: function getDefaultProps() {
@@ -107,7 +108,8 @@ var Link = (0, _createReactClass2.default)({
107
108
  activeClassName = _props.activeClassName,
108
109
  activeStyle = _props.activeStyle,
109
110
  onlyActiveOnIndex = _props.onlyActiveOnIndex,
110
- props = _objectWithoutProperties(_props, ['to', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex']);
111
+ innerRef = _props.innerRef,
112
+ props = _objectWithoutProperties(_props, ['to', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex', 'innerRef']);
111
113
 
112
114
  // Ignore if rendered outside the context of router to simplify unit testing.
113
115
 
@@ -118,7 +120,7 @@ var Link = (0, _createReactClass2.default)({
118
120
  if (router) {
119
121
  // If user does not specify a `to` prop, return an empty anchor tag.
120
122
  if (!to) {
121
- return _react2.default.createElement('a', props);
123
+ return _react2.default.createElement('a', _extends({}, props, { ref: innerRef }));
122
124
  }
123
125
 
124
126
  var toLocation = resolveToLocation(to, router);
@@ -139,7 +141,7 @@ var Link = (0, _createReactClass2.default)({
139
141
  }
140
142
  }
141
143
 
142
- return _react2.default.createElement('a', _extends({}, props, { onClick: this.handleClick }));
144
+ return _react2.default.createElement('a', _extends({}, props, { onClick: this.handleClick, ref: innerRef }));
143
145
  }
144
146
  });
145
147
 
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'];
@@ -14,6 +14,8 @@ var _react = require('react');
14
14
 
15
15
  var _react2 = _interopRequireDefault(_react);
16
16
 
17
+ var _reactIs = require('react-is');
18
+
17
19
  var _createReactClass = require('create-react-class');
18
20
 
19
21
  var _createReactClass2 = _interopRequireDefault(_createReactClass);
@@ -102,7 +104,9 @@ var RouterContext = (0, _createReactClass2.default)({
102
104
  }
103
105
  }
104
106
 
105
- if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object') {
107
+ // Handle components is object for { [name]: component } but not valid element
108
+ // type of react, such as React.memo, React.lazy and so on.
109
+ if ((typeof components === 'undefined' ? 'undefined' : _typeof(components)) === 'object' && !(0, _reactIs.isValidElementType)(components)) {
106
110
  var elements = {};
107
111
 
108
112
  for (var key in components) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "3.2.1",
3
+ "version": "3.2.5",
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",
@@ -38,7 +39,8 @@
38
39
  "hoist-non-react-statics": "^2.3.1",
39
40
  "invariant": "^2.2.1",
40
41
  "loose-envify": "^1.2.0",
41
- "prop-types": "^15.5.6",
42
+ "prop-types": "^15.7.2",
43
+ "react-is": "^16.8.6",
42
44
  "warning": "^3.0.0"
43
45
  },
44
46
  "peerDependencies": {
@@ -68,7 +70,7 @@
68
70
  "express": "^4.14.0",
69
71
  "express-urlrewrite": "^1.2.0",
70
72
  "gzip-size": "^4.1.0",
71
- "karma": "^2.0.0",
73
+ "karma": "^4.1.0",
72
74
  "karma-browserstack-launcher": "^1.0.1",
73
75
  "karma-chrome-launcher": "^2.0.0",
74
76
  "karma-coverage": "^1.1.1",
@@ -79,9 +81,9 @@
79
81
  "mocha": "^5.0.4",
80
82
  "pretty-bytes": "^4.0.2",
81
83
  "qs": "^6.2.1",
82
- "react": "^16.0.0-rc",
84
+ "react": "^16.9.0",
83
85
  "react-addons-css-transition-group": "^15.6.0",
84
- "react-dom": "^16.0.0-rc",
86
+ "react-dom": "^16.9.0",
85
87
  "rimraf": "^2.5.4",
86
88
  "style-loader": "^0.16.1",
87
89
  "webpack": "^1.13.1",