mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
react-router has a new context type in v2.0.0, so added that. Updated tests.
This commit is contained in:
@@ -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<{}, {}> {
|
||||
|
||||
|
||||
8
react-router/react-router.d.ts
vendored
8
react-router/react-router.d.ts
vendored
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user