Skip to content

Commit a68573b

Browse files
committed
added ability to pass router-async route objects
1 parent 601e352 commit a68573b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/router.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export default class Router extends React.Component<Props, State> {
6565
}
6666
static async init(opts: initParams): Promise<initResult> {
6767
const { path, routes, hooks, history = null, silent = false, ctx = new Context() } = opts;
68-
const plainRoutes = Router.buildRoutes(routes);
68+
let plainRoutes;
69+
if ((Array.isArray(routes) && React.isValidElement(routes[0])) || React.isValidElement(routes)) {
70+
plainRoutes = Router.buildRoutes(routes);
71+
} else {
72+
plainRoutes = routes;
73+
}
6974
const router = new RouterAsync({ routes: plainRoutes, hooks });
7075
const { location, route, status, params, redirect, result } = await router.run({ path, ctx, silent });
7176
const componentProps = {

0 commit comments

Comments
 (0)