本页还没有译文
本页 19 段还没译成한국어,下面显示的是英文原文。createStaticRouter
还没翻译译自英文(reactrouter.com)本页 19 段都还没译
createStaticRouter
Data
Summary
Create a static DataRouter for server-side rendering
export async function handleRequest(request: Request) {
let { query, dataRoutes } = createStaticHandler(routes);
let context = await query(request);
if (context instanceof Response) {
return context;
}
let router = createStaticRouter(dataRoutes, context);
return new Response(
ReactDOMServer.renderToString(<StaticRouterProvider ... />),
{ headers: { "Content-Type": "text/html" } }
);
}Signature
function createStaticRouter(
routes: RouteObject[],
context: StaticHandlerContext,
opts: {},
)Params
routes
The route objects to create a static DataRouter for
context
The StaticHandlerContext returned from StaticHandler's query
opts.future
Future flags for the static DataRouter
opts.branches
Deprecated optional pre-computed route branches. This option is no longer used because branch caching is done automatically inside the static router.
Returns
A static DataRouter that can be used to render the provided routes
AI 翻译查看英文原文