react-router has a new context type in v2.0.0, so added that. Updated tests.

This commit is contained in:
Nathan Brown
2016-02-25 16:10:52 -07:00
parent d89fabadf4
commit 156aee9c2e
3 changed files with 21 additions and 3 deletions

View File

@@ -12,6 +12,16 @@ import { browserHistory, hashHistory, Router, Route, IndexRoute, Link } from "re
class Master extends React.Component<React.Props<{}>, {}> {
navigate() {
var router = this.context["router"] as ReactRouter.RouterOnContext;
router.push("/users");
router.push({
pathname: "/users/12",
query: { modal: true },
state: { fromDashboard: true }
});
}
render() {
return <div>
<h1>Master</h1>
@@ -22,6 +32,10 @@ class Master extends React.Component<React.Props<{}>, {}> {
}
(Master as React.ComponentClass<{}>).contextTypes = {
router: React.PropTypes.object,
};
class Dashboard extends React.Component<{}, {}> {

View File

@@ -1,6 +1,6 @@
// Type definitions for react-router v2.0.0-rc5
// Type definitions for react-router v2.0.0
// Project: https://github.com/rackt/react-router
// Definitions by: Sergey Buturlakin <http://github.com/sergey-buturlakin>, Yuichi Murata <https://github.com/mrk21>, Václav Ostrožlík <https://github.com/vasek17>
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Yuichi Murata <https://github.com/mrk21>, Václav Ostrožlík <https://github.com/vasek17>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -195,6 +195,10 @@ declare namespace ReactRouter {
interface IndexRedirectElement extends React.ReactElement<IndexRedirectProps> {}
const IndexRedirect: IndexRedirect
interface RouterOnContext extends H.History {
setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void;
isActive(pathOrLoc: H.LocationDescriptor, indexOnly?: boolean): boolean;
}
/* mixins */