mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Added router and createElement to MatchState. Added tests to demonstrate SSR using match and RouterContext
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
|
||||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
import {renderToString} from "react-dom/server";
|
||||
|
||||
import { browserHistory, hashHistory, createMemoryHistory, withRouter, Router, Route, IndexRoute, Link} from "react-router"
|
||||
import { browserHistory, hashHistory, createMemoryHistory, match, withRouter, Router, RouterContext, Route, IndexRoute, Link} from "react-router"
|
||||
import { routerShape, locationShape } from "react-router/lib/PropTypes"
|
||||
|
||||
interface MasterContext {
|
||||
@@ -99,3 +100,16 @@ ReactDOM.render((
|
||||
</Route>
|
||||
</Router>
|
||||
), document.body)
|
||||
|
||||
|
||||
const history = createMemoryHistory("baseurl");
|
||||
const routes = (
|
||||
<Route path="/" component={Master}>
|
||||
<IndexRoute component={DashboardWithRouter} />
|
||||
<Route path="users" component={Users}/>
|
||||
</Route>
|
||||
);
|
||||
|
||||
match({history, routes, location: "baseurl"}, (error, redirectLocation, renderProps) => {
|
||||
renderToString(<RouterContext {...renderProps} />);
|
||||
});
|
||||
|
||||
Vendored
+2
@@ -275,6 +275,8 @@ declare namespace ReactRouter {
|
||||
}
|
||||
interface MatchState extends RouterState {
|
||||
history: History
|
||||
router: Router
|
||||
createElement: (component: RouteComponent, props: Object) => any
|
||||
}
|
||||
function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void
|
||||
|
||||
|
||||
Reference in New Issue
Block a user