Skip to main content

createRoutesStub

还没翻译译自英文(reactrouter.com)本页 16 段都还没译

createRoutesStub

Framework Data

Summary

Reference Documentation ↗

Creates a React component that renders the provided routes in a test-friendly React Router context.

Use this to unit test components that rely on router context, such as loaderData, actionData, and route matches.

Signature

function createRoutesStub(
  routes: StubRouteObject[],
  _context?: RouterContextProvider,
)

Params

routes

The route objects to render in the test router.

_context

An optional RouterContextProvider for supplying application context values to route middleware, loaders, and actions.

Returns

A React component that renders the test router.

Traducción © 2026 fanyi.dev · Original © 2026 React Training LLC, Remix Software Inc., Shopify Inc. (MIT)