react-router 4.0.0-beta.7 → 4.1.1

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/MemoryRouter.js CHANGED
@@ -6,6 +6,10 @@ var _react = require('react');
6
6
 
7
7
  var _react2 = _interopRequireDefault(_react);
8
8
 
9
+ var _propTypes = require('prop-types');
10
+
11
+ var _propTypes2 = _interopRequireDefault(_propTypes);
12
+
9
13
  var _createMemoryHistory = require('history/createMemoryHistory');
10
14
 
11
15
  var _createMemoryHistory2 = _interopRequireDefault(_createMemoryHistory);
@@ -48,10 +52,10 @@ var MemoryRouter = function (_React$Component) {
48
52
  }(_react2.default.Component);
49
53
 
50
54
  MemoryRouter.propTypes = {
51
- initialEntries: _react.PropTypes.array,
52
- initialIndex: _react.PropTypes.number,
53
- getUserConfirmation: _react.PropTypes.func,
54
- keyLength: _react.PropTypes.number,
55
- children: _react.PropTypes.node
55
+ initialEntries: _propTypes2.default.array,
56
+ initialIndex: _propTypes2.default.number,
57
+ getUserConfirmation: _propTypes2.default.func,
58
+ keyLength: _propTypes2.default.number,
59
+ children: _propTypes2.default.node
56
60
  };
57
61
  exports.default = MemoryRouter;
package/Prompt.js CHANGED
@@ -6,6 +6,10 @@ var _react = require('react');
6
6
 
7
7
  var _react2 = _interopRequireDefault(_react);
8
8
 
9
+ var _propTypes = require('prop-types');
10
+
11
+ var _propTypes2 = _interopRequireDefault(_propTypes);
12
+
9
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
14
 
11
15
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -30,7 +34,7 @@ var Prompt = function (_React$Component) {
30
34
  Prompt.prototype.enable = function enable(message) {
31
35
  if (this.unblock) this.unblock();
32
36
 
33
- this.unblock = this.context.history.block(message);
37
+ this.unblock = this.context.router.history.block(message);
34
38
  };
35
39
 
36
40
  Prompt.prototype.disable = function disable() {
@@ -63,16 +67,18 @@ var Prompt = function (_React$Component) {
63
67
  return Prompt;
64
68
  }(_react2.default.Component);
65
69
 
66
- Prompt.contextTypes = {
67
- history: _react.PropTypes.shape({
68
- block: _react.PropTypes.func.isRequired
69
- }).isRequired
70
- };
71
70
  Prompt.propTypes = {
72
- when: _react.PropTypes.bool,
73
- message: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.string]).isRequired
71
+ when: _propTypes2.default.bool,
72
+ message: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]).isRequired
74
73
  };
75
74
  Prompt.defaultProps = {
76
75
  when: true
77
76
  };
77
+ Prompt.contextTypes = {
78
+ router: _propTypes2.default.shape({
79
+ history: _propTypes2.default.shape({
80
+ block: _propTypes2.default.func.isRequired
81
+ }).isRequired
82
+ }).isRequired
83
+ };
78
84
  exports.default = Prompt;
package/README.md CHANGED
@@ -6,7 +6,7 @@ Declarative routing for [React](https://facebook.github.io/react).
6
6
 
7
7
  Using [npm](https://www.npmjs.com/):
8
8
 
9
- $ npm install --save react-router@next
9
+ $ npm install --save react-router
10
10
 
11
11
  Then with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:
12
12
 
@@ -23,7 +23,7 @@ var Switch = require('react-router').Switch
23
23
  The UMD build is also available on [unpkg](https://unpkg.com):
24
24
 
25
25
  ```html
26
- <script src="https://unpkg.com/react-router@next/umd/react-router.min.js"></script>
26
+ <script src="https://unpkg.com/react-router/umd/react-router.min.js"></script>
27
27
  ```
28
28
 
29
29
  You can find the library on `window.ReactRouter`.
package/Redirect.js CHANGED
@@ -6,6 +6,10 @@ var _react = require('react');
6
6
 
7
7
  var _react2 = _interopRequireDefault(_react);
8
8
 
9
+ var _propTypes = require('prop-types');
10
+
11
+ var _propTypes2 = _interopRequireDefault(_propTypes);
12
+
9
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
14
 
11
15
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -27,16 +31,20 @@ var Redirect = function (_React$Component) {
27
31
  return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
28
32
  }
29
33
 
34
+ Redirect.prototype.isStatic = function isStatic() {
35
+ return this.context.router && this.context.router.staticContext;
36
+ };
37
+
30
38
  Redirect.prototype.componentWillMount = function componentWillMount() {
31
- if (this.context.history.staticContext) this.perform();
39
+ if (this.isStatic()) this.perform();
32
40
  };
33
41
 
34
42
  Redirect.prototype.componentDidMount = function componentDidMount() {
35
- if (!this.context.history.staticContext) this.perform();
43
+ if (!this.isStatic()) this.perform();
36
44
  };
37
45
 
38
46
  Redirect.prototype.perform = function perform() {
39
- var history = this.context.history;
47
+ var history = this.context.router.history;
40
48
  var _props = this.props,
41
49
  push = _props.push,
42
50
  to = _props.to;
@@ -56,18 +64,21 @@ var Redirect = function (_React$Component) {
56
64
  return Redirect;
57
65
  }(_react2.default.Component);
58
66
 
59
- Redirect.contextTypes = {
60
- history: _react.PropTypes.shape({
61
- push: _react.PropTypes.func.isRequired,
62
- replace: _react.PropTypes.func.isRequired,
63
- staticContext: _react.PropTypes.object
64
- }).isRequired
65
- };
66
67
  Redirect.propTypes = {
67
- push: _react.PropTypes.bool,
68
- to: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object])
68
+ push: _propTypes2.default.bool,
69
+ from: _propTypes2.default.string,
70
+ to: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object])
69
71
  };
70
72
  Redirect.defaultProps = {
71
73
  push: false
72
74
  };
75
+ Redirect.contextTypes = {
76
+ router: _propTypes2.default.shape({
77
+ history: _propTypes2.default.shape({
78
+ push: _propTypes2.default.func.isRequired,
79
+ replace: _propTypes2.default.func.isRequired
80
+ }).isRequired,
81
+ staticContext: _propTypes2.default.object
82
+ }).isRequired
83
+ };
73
84
  exports.default = Redirect;
package/Route.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
 
5
+ 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; };
6
+
5
7
  var _warning = require('warning');
6
8
 
7
9
  var _warning2 = _interopRequireDefault(_warning);
@@ -10,6 +12,10 @@ var _react = require('react');
10
12
 
11
13
  var _react2 = _interopRequireDefault(_react);
12
14
 
15
+ var _propTypes = require('prop-types');
16
+
17
+ var _propTypes2 = _interopRequireDefault(_propTypes);
18
+
13
19
  var _matchPath = require('./matchPath');
14
20
 
15
21
  var _matchPath2 = _interopRequireDefault(_matchPath);
@@ -38,16 +44,18 @@ var Route = function (_React$Component) {
38
44
  }
39
45
 
40
46
  return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
41
- match: _this.computeMatch(_this.props, _this.context)
47
+ match: _this.computeMatch(_this.props, _this.context.router)
42
48
  }, _temp), _possibleConstructorReturn(_this, _ret);
43
49
  }
44
50
 
45
51
  Route.prototype.getChildContext = function getChildContext() {
46
52
  return {
47
- route: {
48
- location: this.props.location || this.context.route.location,
49
- match: this.state.match
50
- }
53
+ router: _extends({}, this.context.router, {
54
+ route: {
55
+ location: this.props.location || this.context.router.route.location,
56
+ match: this.state.match
57
+ }
58
+ })
51
59
  };
52
60
  };
53
61
 
@@ -63,7 +71,21 @@ var Route = function (_React$Component) {
63
71
 
64
72
  var pathname = (location || route.location).pathname;
65
73
 
66
- return (0, _matchPath2.default)(pathname, { path: path, strict: strict, exact: exact });
74
+ return path ? (0, _matchPath2.default)(pathname, { path: path, strict: strict, exact: exact }) : route.match;
75
+ };
76
+
77
+ Route.prototype.componentWillMount = function componentWillMount() {
78
+ var _props = this.props,
79
+ component = _props.component,
80
+ render = _props.render,
81
+ children = _props.children;
82
+
83
+
84
+ (0, _warning2.default)(!(component && render), 'You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored');
85
+
86
+ (0, _warning2.default)(!(component && children), 'You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored');
87
+
88
+ (0, _warning2.default)(!(render && children), 'You should not use <Route render> and <Route children> in the same route; <Route children> will be ignored');
67
89
  };
68
90
 
69
91
  Route.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps, nextContext) {
@@ -72,22 +94,23 @@ var Route = function (_React$Component) {
72
94
  (0, _warning2.default)(!(!nextProps.location && this.props.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.');
73
95
 
74
96
  this.setState({
75
- match: this.computeMatch(nextProps, nextContext)
97
+ match: this.computeMatch(nextProps, nextContext.router)
76
98
  });
77
99
  };
78
100
 
79
101
  Route.prototype.render = function render() {
80
102
  var match = this.state.match;
81
- var _props = this.props,
82
- children = _props.children,
83
- component = _props.component,
84
- render = _props.render;
85
- var _context = this.context,
86
- history = _context.history,
87
- route = _context.route;
103
+ var _props2 = this.props,
104
+ children = _props2.children,
105
+ component = _props2.component,
106
+ render = _props2.render;
107
+ var _context$router = this.context.router,
108
+ history = _context$router.history,
109
+ route = _context$router.route,
110
+ staticContext = _context$router.staticContext;
88
111
 
89
112
  var location = this.props.location || route.location;
90
- var props = { match: match, location: location, history: history };
113
+ var props = { match: match, location: location, history: history, staticContext: staticContext };
91
114
 
92
115
  return component ? // component prop gets first priority, only called if there's a match
93
116
  match ? _react2.default.createElement(component, props) : null : render ? // render prop is next, only called if there's a match
@@ -99,21 +122,24 @@ var Route = function (_React$Component) {
99
122
  return Route;
100
123
  }(_react2.default.Component);
101
124
 
102
- Route.contextTypes = {
103
- history: _react.PropTypes.object.isRequired,
104
- route: _react.PropTypes.object.isRequired
105
- };
106
125
  Route.propTypes = {
107
- computedMatch: _react.PropTypes.object, // private, from <Switch>
108
- path: _react.PropTypes.string,
109
- exact: _react.PropTypes.bool,
110
- strict: _react.PropTypes.bool,
111
- component: _react.PropTypes.func,
112
- render: _react.PropTypes.func,
113
- children: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.node]),
114
- location: _react.PropTypes.object
126
+ computedMatch: _propTypes2.default.object, // private, from <Switch>
127
+ path: _propTypes2.default.string,
128
+ exact: _propTypes2.default.bool,
129
+ strict: _propTypes2.default.bool,
130
+ component: _propTypes2.default.func,
131
+ render: _propTypes2.default.func,
132
+ children: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.node]),
133
+ location: _propTypes2.default.object
134
+ };
135
+ Route.contextTypes = {
136
+ router: _propTypes2.default.shape({
137
+ history: _propTypes2.default.object.isRequired,
138
+ route: _propTypes2.default.object.isRequired,
139
+ staticContext: _propTypes2.default.object
140
+ })
115
141
  };
116
142
  Route.childContextTypes = {
117
- route: _react.PropTypes.object.isRequired
143
+ router: _propTypes2.default.object.isRequired
118
144
  };
119
145
  exports.default = Route;
package/Router.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
 
5
+ 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; };
6
+
5
7
  var _warning = require('warning');
6
8
 
7
9
  var _warning2 = _interopRequireDefault(_warning);
@@ -14,6 +16,10 @@ var _react = require('react');
14
16
 
15
17
  var _react2 = _interopRequireDefault(_react);
16
18
 
19
+ var _propTypes = require('prop-types');
20
+
21
+ var _propTypes2 = _interopRequireDefault(_propTypes);
22
+
17
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
24
 
19
25
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -44,11 +50,13 @@ var Router = function (_React$Component) {
44
50
 
45
51
  Router.prototype.getChildContext = function getChildContext() {
46
52
  return {
47
- history: this.props.history,
48
- route: {
49
- location: this.props.history.location,
50
- match: this.state.match
51
- }
53
+ router: _extends({}, this.context.router, {
54
+ history: this.props.history,
55
+ route: {
56
+ location: this.props.history.location,
57
+ match: this.state.match
58
+ }
59
+ })
52
60
  };
53
61
  };
54
62
 
@@ -99,11 +107,13 @@ var Router = function (_React$Component) {
99
107
  }(_react2.default.Component);
100
108
 
101
109
  Router.propTypes = {
102
- history: _react.PropTypes.object.isRequired,
103
- children: _react.PropTypes.node
110
+ history: _propTypes2.default.object.isRequired,
111
+ children: _propTypes2.default.node
112
+ };
113
+ Router.contextTypes = {
114
+ router: _propTypes2.default.object
104
115
  };
105
116
  Router.childContextTypes = {
106
- history: _react.PropTypes.object.isRequired,
107
- route: _react.PropTypes.object.isRequired
117
+ router: _propTypes2.default.object.isRequired
108
118
  };
109
119
  exports.default = Router;
package/StaticRouter.js CHANGED
@@ -12,6 +12,10 @@ var _react = require('react');
12
12
 
13
13
  var _react2 = _interopRequireDefault(_react);
14
14
 
15
+ var _propTypes = require('prop-types');
16
+
17
+ var _propTypes2 = _interopRequireDefault(_propTypes);
18
+
15
19
  var _PathUtils = require('history/PathUtils');
16
20
 
17
21
  var _Router = require('./Router');
@@ -124,6 +128,14 @@ var StaticRouter = function (_React$Component) {
124
128
  }, _temp), _possibleConstructorReturn(_this, _ret);
125
129
  }
126
130
 
131
+ StaticRouter.prototype.getChildContext = function getChildContext() {
132
+ return {
133
+ router: {
134
+ staticContext: this.props.context
135
+ }
136
+ };
137
+ };
138
+
127
139
  StaticRouter.prototype.render = function render() {
128
140
  var _props = this.props,
129
141
  basename = _props.basename,
@@ -132,7 +144,6 @@ var StaticRouter = function (_React$Component) {
132
144
  props = _objectWithoutProperties(_props, ['basename', 'context', 'location']);
133
145
 
134
146
  var history = {
135
- staticContext: context,
136
147
  createHref: this.createHref,
137
148
  action: 'POP',
138
149
  location: stripBasename(basename, createLocation(location)),
@@ -152,12 +163,15 @@ var StaticRouter = function (_React$Component) {
152
163
  }(_react2.default.Component);
153
164
 
154
165
  StaticRouter.propTypes = {
155
- basename: _react.PropTypes.string,
156
- context: _react.PropTypes.object.isRequired,
157
- location: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object])
166
+ basename: _propTypes2.default.string,
167
+ context: _propTypes2.default.object.isRequired,
168
+ location: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object])
158
169
  };
159
170
  StaticRouter.defaultProps = {
160
171
  basename: '',
161
172
  location: '/'
162
173
  };
174
+ StaticRouter.childContextTypes = {
175
+ router: _propTypes2.default.object.isRequired
176
+ };
163
177
  exports.default = StaticRouter;
package/Switch.js CHANGED
@@ -6,6 +6,10 @@ var _react = require('react');
6
6
 
7
7
  var _react2 = _interopRequireDefault(_react);
8
8
 
9
+ var _propTypes = require('prop-types');
10
+
11
+ var _propTypes2 = _interopRequireDefault(_propTypes);
12
+
9
13
  var _warning = require('warning');
10
14
 
11
15
  var _warning2 = _interopRequireDefault(_warning);
@@ -41,16 +45,27 @@ var Switch = function (_React$Component) {
41
45
  };
42
46
 
43
47
  Switch.prototype.render = function render() {
48
+ var route = this.context.router.route;
44
49
  var children = this.props.children;
45
50
 
46
- var location = this.props.location || this.context.route.location;
51
+ var location = this.props.location || route.location;
47
52
 
48
53
  var match = void 0,
49
54
  child = void 0;
50
55
  _react2.default.Children.forEach(children, function (element) {
56
+ if (!_react2.default.isValidElement(element)) return;
57
+
58
+ var _element$props = element.props,
59
+ pathProp = _element$props.path,
60
+ exact = _element$props.exact,
61
+ strict = _element$props.strict,
62
+ from = _element$props.from;
63
+
64
+ var path = pathProp || from;
65
+
51
66
  if (match == null) {
52
67
  child = element;
53
- match = (0, _matchPath2.default)(location.pathname, element.props);
68
+ match = path ? (0, _matchPath2.default)(location.pathname, { path: path, exact: exact, strict: strict }) : route.match;
54
69
  }
55
70
  });
56
71
 
@@ -61,10 +76,12 @@ var Switch = function (_React$Component) {
61
76
  }(_react2.default.Component);
62
77
 
63
78
  Switch.contextTypes = {
64
- route: _react.PropTypes.object.isRequired
79
+ router: _propTypes2.default.shape({
80
+ route: _propTypes2.default.object.isRequired
81
+ }).isRequired
65
82
  };
66
83
  Switch.propTypes = {
67
- children: _react.PropTypes.node,
68
- location: _react.PropTypes.object
84
+ children: _propTypes2.default.node,
85
+ location: _propTypes2.default.object
69
86
  };
70
87
  exports.default = Switch;
@@ -4,7 +4,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
4
4
 
5
5
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
6
6
 
7
- import React, { PropTypes } from 'react';
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
8
9
  import createHistory from 'history/createMemoryHistory';
9
10
  import Router from './Router';
10
11
 
package/es/Prompt.js CHANGED
@@ -4,7 +4,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
4
4
 
5
5
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
6
6
 
7
- import React, { PropTypes } from 'react';
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
8
9
 
9
10
  /**
10
11
  * The public API for prompting the user before navigating away
@@ -23,7 +24,7 @@ var Prompt = function (_React$Component) {
23
24
  Prompt.prototype.enable = function enable(message) {
24
25
  if (this.unblock) this.unblock();
25
26
 
26
- this.unblock = this.context.history.block(message);
27
+ this.unblock = this.context.router.history.block(message);
27
28
  };
28
29
 
29
30
  Prompt.prototype.disable = function disable() {
@@ -56,11 +57,6 @@ var Prompt = function (_React$Component) {
56
57
  return Prompt;
57
58
  }(React.Component);
58
59
 
59
- Prompt.contextTypes = {
60
- history: PropTypes.shape({
61
- block: PropTypes.func.isRequired
62
- }).isRequired
63
- };
64
60
  Prompt.propTypes = {
65
61
  when: PropTypes.bool,
66
62
  message: PropTypes.oneOfType([PropTypes.func, PropTypes.string]).isRequired
@@ -68,6 +64,13 @@ Prompt.propTypes = {
68
64
  Prompt.defaultProps = {
69
65
  when: true
70
66
  };
67
+ Prompt.contextTypes = {
68
+ router: PropTypes.shape({
69
+ history: PropTypes.shape({
70
+ block: PropTypes.func.isRequired
71
+ }).isRequired
72
+ }).isRequired
73
+ };
71
74
 
72
75
 
73
76
  export default Prompt;
package/es/Redirect.js CHANGED
@@ -4,7 +4,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
4
4
 
5
5
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
6
6
 
7
- import React, { PropTypes } from 'react';
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
8
9
 
9
10
  /**
10
11
  * The public API for updating the location programatically
@@ -20,16 +21,20 @@ var Redirect = function (_React$Component) {
20
21
  return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
21
22
  }
22
23
 
24
+ Redirect.prototype.isStatic = function isStatic() {
25
+ return this.context.router && this.context.router.staticContext;
26
+ };
27
+
23
28
  Redirect.prototype.componentWillMount = function componentWillMount() {
24
- if (this.context.history.staticContext) this.perform();
29
+ if (this.isStatic()) this.perform();
25
30
  };
26
31
 
27
32
  Redirect.prototype.componentDidMount = function componentDidMount() {
28
- if (!this.context.history.staticContext) this.perform();
33
+ if (!this.isStatic()) this.perform();
29
34
  };
30
35
 
31
36
  Redirect.prototype.perform = function perform() {
32
- var history = this.context.history;
37
+ var history = this.context.router.history;
33
38
  var _props = this.props,
34
39
  push = _props.push,
35
40
  to = _props.to;
@@ -49,20 +54,23 @@ var Redirect = function (_React$Component) {
49
54
  return Redirect;
50
55
  }(React.Component);
51
56
 
52
- Redirect.contextTypes = {
53
- history: PropTypes.shape({
54
- push: PropTypes.func.isRequired,
55
- replace: PropTypes.func.isRequired,
56
- staticContext: PropTypes.object
57
- }).isRequired
58
- };
59
57
  Redirect.propTypes = {
60
58
  push: PropTypes.bool,
59
+ from: PropTypes.string,
61
60
  to: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
62
61
  };
63
62
  Redirect.defaultProps = {
64
63
  push: false
65
64
  };
65
+ Redirect.contextTypes = {
66
+ router: PropTypes.shape({
67
+ history: PropTypes.shape({
68
+ push: PropTypes.func.isRequired,
69
+ replace: PropTypes.func.isRequired
70
+ }).isRequired,
71
+ staticContext: PropTypes.object
72
+ }).isRequired
73
+ };
66
74
 
67
75
 
68
76
  export default Redirect;