本页还没有译文
本页 17 段还没译成简体中文,下面显示的是英文原文。createStaticHandler
还没翻译译自英文(reactrouter.com)本页 17 段都还没译
createStaticHandler
Data
Summary
Create a static handler to perform server-side data loading
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 createStaticHandler(
routes: RouteObject[],
opts?: CreateStaticHandlerOptions,
): StaticHandlerParams
routes
The route objects to create a static handler for
opts.basename
The base URL for the static handler (default: /)
opts.future
Future flags for the static handler
Returns
A static handler that can be used to query data for the provided routes
AI 翻译查看英文原文