Add another signature to match()

This commit is contained in:
Karol Janyst
2017-02-03 09:05:37 +09:00
parent 9e4ef164d6
commit fb82c5984f
2 changed files with 16 additions and 4 deletions
+11 -3
View File
@@ -3,14 +3,22 @@ import { Basename, LocationDescriptor, ParseQueryString, RouteConfig, StringifyQ
interface MatchArgs {
routes: RouteConfig;
location: LocationDescriptor;
history?: History;
basename?: Basename;
parseQueryString?: ParseQueryString;
stringifyQuery?: StringifyQuery;
}
interface MatchLocationArgs extends MatchArgs {
location: LocationDescriptor;
history?: History;
}
interface MatchHistoryArgs extends MatchArgs {
location?: LocationDescriptor;
history: History;
}
export type MatchCallback = (error: any, redirectLocation: Location, renderProps: any) => void;
export default function match(args: MatchArgs, cb: MatchCallback): void;
export default function match(args: MatchLocationArgs | MatchHistoryArgs, cb: MatchCallback): void;
+5 -1
View File
@@ -123,7 +123,11 @@ const routes = (
</Route>
);
match({history, routes, location: "baseurl"}, (error, redirectLocation, renderProps) => {
match({ routes, location: "baseurl" }, (error, redirectLocation, renderProps) => {
renderToString(<RouterContext {...renderProps} />);
});
match({ history, routes }, (error, redirectLocation, renderProps) => {
renderToString(<RouterContext {...renderProps} />);
});