Skip to content

Commit e5ad53b

Browse files
committed
Un-deprecate Navigation and State mixins
1 parent 06c15c5 commit e5ad53b

File tree

2 files changed

+24
-48
lines changed

2 files changed

+24
-48
lines changed

modules/Navigation.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
var warning = require('react/lib/warning');
21
var PropTypes = require('./PropTypes');
32

4-
function deprecatedMethod(routerMethodName, fn) {
5-
return function () {
6-
warning(
7-
false,
8-
`Router.Navigation is deprecated. Please use this.context.router.${routerMethodName}() instead`
9-
);
10-
11-
return fn.apply(this, arguments);
12-
};
13-
}
14-
153
/**
164
* A mixin for components that modify the URL.
175
*
@@ -40,40 +28,40 @@ var Navigation = {
4028
* Returns an absolute URL path created from the given route
4129
* name, URL parameters, and query values.
4230
*/
43-
makePath: deprecatedMethod('makePath', function (to, params, query) {
31+
makePath(to, params, query) {
4432
return this.context.router.makePath(to, params, query);
45-
}),
33+
},
4634

4735
/**
4836
* Returns a string that may safely be used as the href of a
4937
* link to the route with the given name.
5038
*/
51-
makeHref: deprecatedMethod('makeHref', function (to, params, query) {
39+
makeHref(to, params, query) {
5240
return this.context.router.makeHref(to, params, query);
53-
}),
41+
},
5442

5543
/**
5644
* Transitions to the URL specified in the arguments by pushing
5745
* a new URL onto the history stack.
5846
*/
59-
transitionTo: deprecatedMethod('transitionTo', function (to, params, query) {
47+
transitionTo(to, params, query) {
6048
this.context.router.transitionTo(to, params, query);
61-
}),
49+
},
6250

6351
/**
6452
* Transitions to the URL specified in the arguments by replacing
6553
* the current URL in the history stack.
6654
*/
67-
replaceWith: deprecatedMethod('replaceWith', function (to, params, query) {
55+
replaceWith(to, params, query) {
6856
this.context.router.replaceWith(to, params, query);
69-
}),
57+
},
7058

7159
/**
7260
* Transitions to the previous URL.
7361
*/
74-
goBack: deprecatedMethod('goBack', function () {
62+
goBack() {
7563
return this.context.router.goBack();
76-
})
64+
}
7765

7866
};
7967

modules/State.js

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
var warning = require('react/lib/warning');
21
var PropTypes = require('./PropTypes');
32

4-
function deprecatedMethod(routerMethodName, fn) {
5-
return function () {
6-
warning(
7-
false,
8-
`Router.State is deprecated. Please use this.context.router.${routerMethodName}() instead`
9-
);
10-
11-
return fn.apply(this, arguments);
12-
};
13-
}
14-
153
/**
164
* A mixin for components that need to know the path, routes, URL
175
* params and query that are currently active.
@@ -22,10 +10,10 @@ function deprecatedMethod(routerMethodName, fn) {
2210
* mixins: [ Router.State ],
2311
* render() {
2412
* var className = this.props.className;
25-
*
13+
*
2614
* if (this.isActive('about'))
2715
* className += ' is-active';
28-
*
16+
*
2917
* return React.DOM.a({ className: className }, this.props.children);
3018
* }
3119
* });
@@ -39,45 +27,45 @@ var State = {
3927
/**
4028
* Returns the current URL path.
4129
*/
42-
getPath: deprecatedMethod('getCurrentPath', function () {
30+
getPath() {
4331
return this.context.router.getCurrentPath();
44-
}),
32+
},
4533

4634
/**
4735
* Returns the current URL path without the query string.
4836
*/
49-
getPathname: deprecatedMethod('getCurrentPathname', function () {
37+
getPathname() {
5038
return this.context.router.getCurrentPathname();
51-
}),
39+
},
5240

5341
/**
5442
* Returns an object of the URL params that are currently active.
5543
*/
56-
getParams: deprecatedMethod('getCurrentParams', function () {
44+
getParams() {
5745
return this.context.router.getCurrentParams();
58-
}),
46+
},
5947

6048
/**
6149
* Returns an object of the query params that are currently active.
6250
*/
63-
getQuery: deprecatedMethod('getCurrentQuery', function () {
51+
getQuery() {
6452
return this.context.router.getCurrentQuery();
65-
}),
53+
},
6654

6755
/**
6856
* Returns an array of the routes that are currently active.
6957
*/
70-
getRoutes: deprecatedMethod('getCurrentRoutes', function () {
58+
getRoutes() {
7159
return this.context.router.getCurrentRoutes();
72-
}),
60+
},
7361

7462
/**
7563
* A helper method to determine if a given route, params, and query
7664
* are active.
7765
*/
78-
isActive: deprecatedMethod('isActive', function (to, params, query) {
66+
isActive(to, params, query) {
7967
return this.context.router.isActive(to, params, query);
80-
})
68+
}
8169

8270
};
8371

0 commit comments

Comments
 (0)