react-router 3.0.1 → 3.0.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/CHANGES.md +38 -0
- package/README.md +6 -1
- package/docs/API.md +6 -3
- package/docs/guides/ConfirmingNavigation.md +3 -0
- package/docs/guides/Histories.md +4 -4
- package/docs/guides/RouteMatching.md +1 -1
- package/es/ContextUtils.js +1 -1
- package/es/IndexLink.js +3 -1
- package/es/IndexRedirect.js +3 -8
- package/es/IndexRoute.js +3 -6
- package/es/InternalPropTypes.js +1 -10
- package/es/Link.js +3 -18
- package/es/PropTypes.js +1 -7
- package/es/Redirect.js +3 -8
- package/es/Route.js +3 -8
- package/es/Router.js +18 -20
- package/es/RouterContext.js +3 -8
- package/es/TransitionUtils.js +113 -105
- package/es/computeChangedRoutes.js +19 -21
- package/es/createRouterHistory.js +1 -1
- package/es/createTransitionManager.js +8 -1
- package/es/matchRoutes.js +23 -31
- package/es/withRouter.js +2 -1
- package/lib/ContextUtils.js +8 -4
- package/lib/IndexLink.js +6 -1
- package/lib/IndexRedirect.js +8 -12
- package/lib/IndexRoute.js +7 -9
- package/lib/InternalPropTypes.js +12 -19
- package/lib/Link.js +13 -24
- package/lib/PropTypes.js +15 -19
- package/lib/Redirect.js +10 -14
- package/lib/Route.js +8 -12
- package/lib/Router.js +22 -20
- package/lib/RouterContext.js +14 -15
- package/lib/TransitionUtils.js +112 -105
- package/lib/computeChangedRoutes.js +19 -21
- package/lib/createRouterHistory.js +6 -6
- package/lib/createTransitionManager.js +12 -3
- package/lib/matchRoutes.js +23 -31
- package/lib/withRouter.js +5 -1
- package/package.json +19 -17
- package/umd/ReactRouter.js +2315 -651
- package/umd/ReactRouter.min.js +6 -2
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## [v3.0.5](https://github.com/ReactTraining/react-router/compare/v3.0.4...v3.0.5)
|
|
2
|
+
> Apr 10, 2017
|
|
3
|
+
|
|
4
|
+
- Manually set displayName for components
|
|
5
|
+
- Async hooks could be removed during simultaneous server requests (#4941 by @s-yadav)
|
|
6
|
+
|
|
7
|
+
## [v3.0.4](https://github.com/ReactTraining/react-router/compare/v3.0.3...v3.0.4)
|
|
8
|
+
> Apr 9, 2017
|
|
9
|
+
|
|
10
|
+
- Fixes for React 15.5 deprecation warnings
|
|
11
|
+
|
|
12
|
+
## [v3.0.3](https://github.com/ReactTraining/react-router/compare/v3.0.2...v3.0.3)
|
|
13
|
+
> Mar 28, 2017
|
|
14
|
+
|
|
15
|
+
- Fix webpack-related anonymous function issue (#4857 by @alisd23)
|
|
16
|
+
- Fix usage with babel-plugin-transform-remove-prop-types (#4505 by @oliviertassinari)
|
|
17
|
+
- Remove references to Link hash/query/state props (#4377 by @insin)
|
|
18
|
+
|
|
19
|
+
## [v3.0.2](https://github.com/ReactTraining/react-router/compare/v3.0.1...v3.0.2)
|
|
20
|
+
> Jan 18, 2017
|
|
21
|
+
|
|
22
|
+
- Re-add module entry to package.json
|
|
23
|
+
|
|
24
|
+
## [v3.0.1](https://github.com/ReactTraining/react-router/compare/v3.0.0...v3.0.1)
|
|
25
|
+
> Jan 12, 2017
|
|
26
|
+
|
|
27
|
+
- Pass transition hook's arguments correctly ([#4123] by @arkist)
|
|
28
|
+
- Fix index routes inside async pathless routes ([#4147] by @taurose)
|
|
29
|
+
- 'to' maybe undefined ([#4216] by @panzj)
|
|
30
|
+
- Fix withRouter error when used without a Router ([#4295] by @dropfen)
|
|
31
|
+
- Adding support for escaped parentheses in Route Paths ([#4202] by @sebastiandeutsch)
|
|
32
|
+
|
|
33
|
+
[#4123]: https://github.com/ReactTraining/react-router/pull/4123
|
|
34
|
+
[#4147]: https://github.com/ReactTraining/react-router/pull/4147
|
|
35
|
+
[#4216]: https://github.com/ReactTraining/react-router/pull/4216
|
|
36
|
+
[#4295]: https://github.com/ReactTraining/react-router/pull/4295
|
|
37
|
+
[#4202]: https://github.com/ReactTraining/react-router/pull/4202
|
|
38
|
+
|
|
1
39
|
## [v3.0.0]
|
|
2
40
|
> Oct 24, 2016
|
|
3
41
|
|
package/README.md
CHANGED
|
@@ -9,11 +9,16 @@ React Router keeps your UI in sync with the URL. It has a simple API with powerf
|
|
|
9
9
|
[![Codecov][codecov-badge]][codecov]
|
|
10
10
|
[![Discord][discord-badge]][discord]
|
|
11
11
|
|
|
12
|
+
### 4.0 is here!
|
|
13
|
+
|
|
14
|
+
The next version of React Router (4.0) has been released! Check out the `master` branch.
|
|
15
|
+
|
|
16
|
+
[4.0 Documentation](https://reacttraining.com/react-router/)
|
|
12
17
|
|
|
13
18
|
### Docs & Help
|
|
14
19
|
|
|
15
20
|
- [Tutorial – do this first!](https://github.com/reactjs/react-router-tutorial)
|
|
16
|
-
- [Guides and API docs](/docs)
|
|
21
|
+
- [Guides and API docs (v2, v3)](/docs)
|
|
17
22
|
- [Troubleshooting guide](https://github.com/ReactTraining/react-router/blob/master/docs/Troubleshooting.md)
|
|
18
23
|
- [Changelog](/CHANGES.md)
|
|
19
24
|
- [Stack Overflow](http://stackoverflow.com/questions/tagged/react-router)
|
package/docs/API.md
CHANGED
|
@@ -535,7 +535,7 @@ A route's component is rendered when that route matches the URL. The router will
|
|
|
535
535
|
### Injected Props
|
|
536
536
|
|
|
537
537
|
#### `location`
|
|
538
|
-
The current [location](https://github.com/
|
|
538
|
+
The current [location](https://github.com/ReactTraining/history/blob/v2/docs/Location.md).
|
|
539
539
|
|
|
540
540
|
#### `params`
|
|
541
541
|
The dynamic segments of the URL.
|
|
@@ -546,6 +546,9 @@ The route that rendered this component.
|
|
|
546
546
|
#### `router`
|
|
547
547
|
Contains methods relevant to routing. Most useful for imperatively transitioning around the application.
|
|
548
548
|
|
|
549
|
+
#### `routes`
|
|
550
|
+
The routes registered with the router.
|
|
551
|
+
|
|
549
552
|
#### `routeParams`
|
|
550
553
|
A subset of `this.props.params` that were directly specified in this component's route. For example, if the route's path is `users/:userId` and the URL is `/users/123/portfolios/345` then `this.props.routeParams` will be `{userId: '123'}`, and `this.props.params` will be `{userId: '123', portfolioId: '345'}`.
|
|
551
554
|
|
|
@@ -645,9 +648,9 @@ For more details, please see the [histories guide](/docs/guides/Histories.md).
|
|
|
645
648
|
`useRouterHistory` is a `history` enhancer that configures a given `createHistory` factory to work with React Router. This allows using custom histories in addition to the bundled singleton histories.
|
|
646
649
|
|
|
647
650
|
It also pre-enhances the history with the
|
|
648
|
-
[useQueries](https://github.com/
|
|
651
|
+
[useQueries](https://github.com/ReactTraining/history/blob/v2/docs/QuerySupport.md)
|
|
649
652
|
and
|
|
650
|
-
[useBasename](https://github.com/
|
|
653
|
+
[useBasename](https://github.com/ReactTraining/history/blob/v2/docs/BasenameSupport.md)
|
|
651
654
|
enhancers from `history`
|
|
652
655
|
|
|
653
656
|
#### Example
|
|
@@ -13,6 +13,9 @@ const Home = withRouter(
|
|
|
13
13
|
routerWillLeave(nextLocation) {
|
|
14
14
|
// return false to prevent a transition w/o prompting the user,
|
|
15
15
|
// or return a string to allow the user to decide:
|
|
16
|
+
// return `null` or nothing to let other hooks to be executed
|
|
17
|
+
//
|
|
18
|
+
// NOTE: if you return true, other hooks will not be executed!
|
|
16
19
|
if (!this.state.isSaved)
|
|
17
20
|
return 'Your work is not saved! Are you sure you want to leave?'
|
|
18
21
|
},
|
package/docs/guides/Histories.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Histories
|
|
2
2
|
|
|
3
|
-
React Router is built with [history](https://github.com/
|
|
3
|
+
React Router is built with [history](https://github.com/ReactTraining/history).
|
|
4
4
|
In a nutshell, a history knows how to listen to the browser's address
|
|
5
5
|
bar for changes and parses the URL into a `location` object that the
|
|
6
6
|
router can use to match routes and render the correct set of components.
|
|
@@ -139,11 +139,11 @@ render(
|
|
|
139
139
|
|
|
140
140
|
If you'd like to further customize the history options or use other
|
|
141
141
|
enhancers from
|
|
142
|
-
[history](https://github.com/
|
|
142
|
+
[history](https://github.com/ReactTraining/history) you can use
|
|
143
143
|
`useRouterHistory`.
|
|
144
144
|
|
|
145
145
|
Be aware that `useRouterHistory` already pre-enhances your history
|
|
146
|
-
factory with the [useQueries](https://github.com/
|
|
146
|
+
factory with the [useQueries](https://github.com/ReactTraining/history/blob/v2/docs/QuerySupport.md) and [useBasename](https://github.com/ReactTraining/history/blob/v2/docs/BasenameSupport.md) enhancers from `history`.
|
|
147
147
|
|
|
148
148
|
### Examples:
|
|
149
149
|
|
|
@@ -159,7 +159,7 @@ const history = useRouterHistory(createHistory)({
|
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
Using the
|
|
162
|
-
[useBeforeUnload](https://github.com/
|
|
162
|
+
[useBeforeUnload](https://github.com/ReactTraining/history/blob/v2/docs/ConfirmingNavigation.md)
|
|
163
163
|
enhancer:
|
|
164
164
|
|
|
165
165
|
```js
|
|
@@ -13,7 +13,7 @@ React Router uses the concept of nested routes to let you declare nested sets of
|
|
|
13
13
|
A route path is [a string pattern](/docs/Glossary.md#routepattern) that is used to match a URL (or a portion of one). Route paths are interpreted literally, except for the following special symbols:
|
|
14
14
|
|
|
15
15
|
- `:paramName` – matches a URL segment up to the next `/`, `?`, or `#`. The matched string is called a [param](/docs/Glossary.md#params)
|
|
16
|
-
- `()` – Wraps a portion of the URL that is optional. You may escape parentheses if you want to use them in a url using a
|
|
16
|
+
- `()` – Wraps a portion of the URL that is optional. You may escape parentheses if you want to use them in a url using a backslash \
|
|
17
17
|
- `*` – Matches all characters (non-greedy) up to the next character in the pattern, or to the end of the URL if there is none, and creates a `splat` [param](/docs/Glossary.md#params)
|
|
18
18
|
- `**` - Matches all characters (greedy) until the next `/`, `?`, or `#` and creates a `splat` [param](/docs/Glossary.md#params)
|
|
19
19
|
|
package/es/ContextUtils.js
CHANGED
package/es/IndexLink.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
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; };
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import createReactClass from 'create-react-class';
|
|
4
5
|
import Link from './Link';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* An <IndexLink> is used to link to an <IndexRoute>.
|
|
8
9
|
*/
|
|
9
|
-
var IndexLink =
|
|
10
|
+
var IndexLink = createReactClass({
|
|
10
11
|
displayName: 'IndexLink',
|
|
12
|
+
|
|
11
13
|
render: function render() {
|
|
12
14
|
return React.createElement(Link, _extends({}, this.props, { onlyActiveOnIndex: true }));
|
|
13
15
|
}
|
package/es/IndexRedirect.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createReactClass from 'create-react-class';
|
|
2
|
+
import { string, object } from 'prop-types';
|
|
2
3
|
import warning from './routerWarning';
|
|
3
4
|
import invariant from 'invariant';
|
|
4
5
|
import Redirect from './Redirect';
|
|
5
6
|
import { falsy } from './InternalPropTypes';
|
|
6
7
|
|
|
7
|
-
var _React$PropTypes = React.PropTypes,
|
|
8
|
-
string = _React$PropTypes.string,
|
|
9
|
-
object = _React$PropTypes.object;
|
|
10
|
-
|
|
11
8
|
/**
|
|
12
9
|
* An <IndexRedirect> is used to redirect from an indexRoute.
|
|
13
10
|
*/
|
|
14
11
|
/* eslint-disable react/require-render-return */
|
|
15
|
-
|
|
16
|
-
var IndexRedirect = React.createClass({
|
|
12
|
+
var IndexRedirect = createReactClass({
|
|
17
13
|
displayName: 'IndexRedirect',
|
|
18
14
|
|
|
19
|
-
|
|
20
15
|
statics: {
|
|
21
16
|
createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) {
|
|
22
17
|
/* istanbul ignore else: sanity check */
|
package/es/IndexRoute.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createReactClass from 'create-react-class';
|
|
2
|
+
import { func } from 'prop-types';
|
|
2
3
|
import warning from './routerWarning';
|
|
3
4
|
import invariant from 'invariant';
|
|
4
5
|
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
|
|
5
6
|
import { component, components, falsy } from './InternalPropTypes';
|
|
6
7
|
|
|
7
|
-
var func = React.PropTypes.func;
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* An <IndexRoute> is used to specify its parent's <Route indexRoute> in
|
|
11
10
|
* a JSX route config.
|
|
12
11
|
*/
|
|
13
12
|
/* eslint-disable react/require-render-return */
|
|
14
|
-
|
|
15
|
-
var IndexRoute = React.createClass({
|
|
13
|
+
var IndexRoute = createReactClass({
|
|
16
14
|
displayName: 'IndexRoute',
|
|
17
15
|
|
|
18
|
-
|
|
19
16
|
statics: {
|
|
20
17
|
createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) {
|
|
21
18
|
/* istanbul ignore else: sanity check */
|
package/es/InternalPropTypes.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var func = PropTypes.func,
|
|
4
|
-
object = PropTypes.object,
|
|
5
|
-
arrayOf = PropTypes.arrayOf,
|
|
6
|
-
oneOfType = PropTypes.oneOfType,
|
|
7
|
-
element = PropTypes.element,
|
|
8
|
-
shape = PropTypes.shape,
|
|
9
|
-
string = PropTypes.string;
|
|
10
|
-
|
|
1
|
+
import { func, object, arrayOf, oneOfType, element, shape, string } from 'prop-types';
|
|
11
2
|
|
|
12
3
|
export function falsy(props, propName, componentName) {
|
|
13
4
|
if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
|
package/es/Link.js
CHANGED
|
@@ -3,18 +3,12 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
|
|
3
3
|
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import createReactClass from 'create-react-class';
|
|
7
|
+
import { bool, object, string, func, oneOfType } from 'prop-types';
|
|
6
8
|
import invariant from 'invariant';
|
|
7
9
|
import { routerShape } from './PropTypes';
|
|
8
10
|
import { ContextSubscriber } from './ContextUtils';
|
|
9
11
|
|
|
10
|
-
var _React$PropTypes = React.PropTypes,
|
|
11
|
-
bool = _React$PropTypes.bool,
|
|
12
|
-
object = _React$PropTypes.object,
|
|
13
|
-
string = _React$PropTypes.string,
|
|
14
|
-
func = _React$PropTypes.func,
|
|
15
|
-
oneOfType = _React$PropTypes.oneOfType;
|
|
16
|
-
|
|
17
|
-
|
|
18
12
|
function isLeftClickEvent(event) {
|
|
19
13
|
return event.button === 0;
|
|
20
14
|
}
|
|
@@ -46,16 +40,10 @@ function resolveToLocation(to, router) {
|
|
|
46
40
|
* You could use the following component to link to that route:
|
|
47
41
|
*
|
|
48
42
|
* <Link to={`/posts/${post.id}`} />
|
|
49
|
-
*
|
|
50
|
-
* Links may pass along location state and/or query string parameters
|
|
51
|
-
* in the state/query props, respectively.
|
|
52
|
-
*
|
|
53
|
-
* <Link ... query={{ show: true }} state={{ the: 'state' }} />
|
|
54
43
|
*/
|
|
55
|
-
var Link =
|
|
44
|
+
var Link = createReactClass({
|
|
56
45
|
displayName: 'Link',
|
|
57
46
|
|
|
58
|
-
|
|
59
47
|
mixins: [ContextSubscriber('router')],
|
|
60
48
|
|
|
61
49
|
contextTypes: {
|
|
@@ -64,9 +52,6 @@ var Link = React.createClass({
|
|
|
64
52
|
|
|
65
53
|
propTypes: {
|
|
66
54
|
to: oneOfType([string, object, func]),
|
|
67
|
-
query: object,
|
|
68
|
-
hash: string,
|
|
69
|
-
state: object,
|
|
70
55
|
activeStyle: object,
|
|
71
56
|
activeClassName: string,
|
|
72
57
|
onlyActiveOnIndex: bool.isRequired,
|
package/es/PropTypes.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
var func = PropTypes.func,
|
|
4
|
-
object = PropTypes.object,
|
|
5
|
-
shape = PropTypes.shape,
|
|
6
|
-
string = PropTypes.string;
|
|
7
|
-
|
|
1
|
+
import { func, object, shape, string } from 'prop-types';
|
|
8
2
|
|
|
9
3
|
export var routerShape = shape({
|
|
10
4
|
push: func.isRequired,
|
package/es/Redirect.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createReactClass from 'create-react-class';
|
|
2
|
+
import { string, object } from 'prop-types';
|
|
2
3
|
import invariant from 'invariant';
|
|
3
4
|
import { createRouteFromReactElement as _createRouteFromReactElement } from './RouteUtils';
|
|
4
5
|
import { formatPattern } from './PatternUtils';
|
|
5
6
|
import { falsy } from './InternalPropTypes';
|
|
6
7
|
|
|
7
|
-
var _React$PropTypes = React.PropTypes,
|
|
8
|
-
string = _React$PropTypes.string,
|
|
9
|
-
object = _React$PropTypes.object;
|
|
10
|
-
|
|
11
8
|
/**
|
|
12
9
|
* A <Redirect> is used to declare another URL path a client should
|
|
13
10
|
* be sent to when they request a given URL.
|
|
@@ -16,11 +13,9 @@ var _React$PropTypes = React.PropTypes,
|
|
|
16
13
|
* and are traversed in the same manner.
|
|
17
14
|
*/
|
|
18
15
|
/* eslint-disable react/require-render-return */
|
|
19
|
-
|
|
20
|
-
var Redirect = React.createClass({
|
|
16
|
+
var Redirect = createReactClass({
|
|
21
17
|
displayName: 'Redirect',
|
|
22
18
|
|
|
23
|
-
|
|
24
19
|
statics: {
|
|
25
20
|
createRouteFromReactElement: function createRouteFromReactElement(element) {
|
|
26
21
|
var route = _createRouteFromReactElement(element);
|
package/es/Route.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createReactClass from 'create-react-class';
|
|
2
|
+
import { string, func } from 'prop-types';
|
|
2
3
|
import invariant from 'invariant';
|
|
3
4
|
import { createRouteFromReactElement } from './RouteUtils';
|
|
4
5
|
import { component, components } from './InternalPropTypes';
|
|
5
6
|
|
|
6
|
-
var _React$PropTypes = React.PropTypes,
|
|
7
|
-
string = _React$PropTypes.string,
|
|
8
|
-
func = _React$PropTypes.func;
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
8
|
* A <Route> is used to declare which components are rendered to the
|
|
12
9
|
* page when the URL matches a given pattern.
|
|
@@ -18,11 +15,9 @@ var _React$PropTypes = React.PropTypes,
|
|
|
18
15
|
* rendered into the DOM, nested in the same order as in the tree.
|
|
19
16
|
*/
|
|
20
17
|
/* eslint-disable react/require-render-return */
|
|
21
|
-
|
|
22
|
-
var Route = React.createClass({
|
|
18
|
+
var Route = createReactClass({
|
|
23
19
|
displayName: 'Route',
|
|
24
20
|
|
|
25
|
-
|
|
26
21
|
statics: {
|
|
27
22
|
createRouteFromReactElement: createRouteFromReactElement
|
|
28
23
|
},
|
package/es/Router.js
CHANGED
|
@@ -4,6 +4,8 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in ob
|
|
|
4
4
|
|
|
5
5
|
import invariant from 'invariant';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import createReactClass from 'create-react-class';
|
|
8
|
+
import { func, object } from 'prop-types';
|
|
7
9
|
|
|
8
10
|
import _createTransitionManager from './createTransitionManager';
|
|
9
11
|
import { routes } from './InternalPropTypes';
|
|
@@ -12,32 +14,28 @@ import { createRoutes } from './RouteUtils';
|
|
|
12
14
|
import { createRouterObject as _createRouterObject, assignRouterState } from './RouterUtils';
|
|
13
15
|
import warning from './routerWarning';
|
|
14
16
|
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
var propTypes = {
|
|
18
|
+
history: object,
|
|
19
|
+
children: routes,
|
|
20
|
+
routes: routes, // alias for children
|
|
21
|
+
render: func,
|
|
22
|
+
createElement: func,
|
|
23
|
+
onError: func,
|
|
24
|
+
onUpdate: func,
|
|
25
|
+
|
|
26
|
+
// PRIVATE: For client-side rehydration of server match.
|
|
27
|
+
matchContext: object
|
|
28
|
+
};
|
|
18
29
|
|
|
19
30
|
/**
|
|
20
31
|
* A <Router> is a high-level API for automatically setting up
|
|
21
32
|
* a router that renders a <RouterContext> with all the props
|
|
22
33
|
* it needs each time the URL changes.
|
|
23
34
|
*/
|
|
24
|
-
|
|
25
|
-
var Router = React.createClass({
|
|
35
|
+
var Router = createReactClass({
|
|
26
36
|
displayName: 'Router',
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
propTypes: {
|
|
30
|
-
history: object,
|
|
31
|
-
children: routes,
|
|
32
|
-
routes: routes, // alias for children
|
|
33
|
-
render: func,
|
|
34
|
-
createElement: func,
|
|
35
|
-
onError: func,
|
|
36
|
-
onUpdate: func,
|
|
37
|
-
|
|
38
|
-
// PRIVATE: For client-side rehydration of server match.
|
|
39
|
-
matchContext: object
|
|
40
|
-
},
|
|
38
|
+
propTypes: propTypes,
|
|
41
39
|
|
|
42
40
|
getDefaultProps: function getDefaultProps() {
|
|
43
41
|
return {
|
|
@@ -86,7 +84,7 @@ var Router = React.createClass({
|
|
|
86
84
|
children = _props.children;
|
|
87
85
|
|
|
88
86
|
|
|
89
|
-
!history.getCurrentLocation ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You have provided a history object created with history
|
|
87
|
+
!history.getCurrentLocation ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You have provided a history object created with history v4.x or v2.x ' + 'and earlier. This version of React Router is only compatible with v3 ' + 'history objects. Please change to history v3.x.') : invariant(false) : void 0;
|
|
90
88
|
|
|
91
89
|
return _createTransitionManager(history, createRoutes(routes || children));
|
|
92
90
|
},
|
|
@@ -134,7 +132,7 @@ var Router = React.createClass({
|
|
|
134
132
|
|
|
135
133
|
// Only forward non-Router-specific props to routing context, as those are
|
|
136
134
|
// the only ones that might be custom routing context props.
|
|
137
|
-
Object.keys(
|
|
135
|
+
Object.keys(propTypes).forEach(function (propType) {
|
|
138
136
|
return delete props[propType];
|
|
139
137
|
});
|
|
140
138
|
|
package/es/RouterContext.js
CHANGED
|
@@ -4,25 +4,20 @@ 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 createReactClass from 'create-react-class';
|
|
8
|
+
import { array, func, object } from 'prop-types';
|
|
7
9
|
|
|
8
10
|
import getRouteParams from './getRouteParams';
|
|
9
11
|
import { ContextProvider } from './ContextUtils';
|
|
10
12
|
import { isReactChildren } from './RouteUtils';
|
|
11
13
|
|
|
12
|
-
var _React$PropTypes = React.PropTypes,
|
|
13
|
-
array = _React$PropTypes.array,
|
|
14
|
-
func = _React$PropTypes.func,
|
|
15
|
-
object = _React$PropTypes.object;
|
|
16
|
-
|
|
17
14
|
/**
|
|
18
15
|
* A <RouterContext> renders the component tree for a given router state
|
|
19
16
|
* and sets the history object and the current location in context.
|
|
20
17
|
*/
|
|
21
|
-
|
|
22
|
-
var RouterContext = React.createClass({
|
|
18
|
+
var RouterContext = createReactClass({
|
|
23
19
|
displayName: 'RouterContext',
|
|
24
20
|
|
|
25
|
-
|
|
26
21
|
mixins: [ContextProvider('router')],
|
|
27
22
|
|
|
28
23
|
propTypes: {
|