feat: migrate experimental app to use react data router
This commit is contained in:
@@ -52,3 +52,16 @@ export const toAsyncPageRoute = ({ path, page, element, type = AsyncRouteType.St
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function toAsyncPageRouteConfig({ path, page, element, type = AsyncRouteType.Stable }: AsyncRoute) {
|
||||
const Element = element || (
|
||||
type === AsyncRouteType.Experimental ?
|
||||
ExperimentalAsyncPage :
|
||||
StableAsyncPage
|
||||
);
|
||||
|
||||
return {
|
||||
path,
|
||||
element: <Element page={page ?? path} />
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,3 +19,10 @@ export function toViewManagerPageRoute(route: LegacyRoute) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function toViewManagerPageRouteConfig(route: LegacyRoute) {
|
||||
return {
|
||||
path: route.path,
|
||||
element: <ViewManagerPage {...route.pageProps} />
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Navigate, Route, useLocation } from 'react-router-dom';
|
||||
import { Navigate, Route, RouteObject, useLocation } from 'react-router-dom';
|
||||
|
||||
export interface Redirect {
|
||||
from: string
|
||||
@@ -26,3 +26,10 @@ export function toRedirectRoute({ from, to }: Redirect) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function toRedirectRouteConfig({ from, to }: Redirect): RouteObject {
|
||||
return {
|
||||
path: from,
|
||||
element: <RedirectWithSearch to={to} />
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user