React Router v6 page adapter. Injects library context projected from the
framework's AppHistoryApi and never writes window.history via
push/replace/go.
children are opaque React Router content (for example <Routes> /
<Route> trees composed by the page itself, or the sub-page the framework
routed to) and are rendered as-is. This adapter builds no routes of its own:
which sub-page of a page is showing is decided by the framework's own route
matching, one level above.
Programmatic back and forward (navigate(-1)) traverse the app-owned
browser history.
Declare it by rendering it inside the lazily loaded page or sub-page component that
should get the context:
// In the lazily loaded page component module: exportfunctionCatalogPage() { return ( <ReactRouterV6PageRouter> {routes} </ReactRouterV6PageRouter> ); }
In a sub-page's component it scopes itself to that sub-page rather than to
the page above it, because the sub-page's own mount is what is in context
there. Adapters nest rather than replace one another, so a v6 sub-page works
under a page rendered by another routing library, and the reverse.
Scoping needs two things: a page mount, saying which part of the URL belongs
to the page, and a registered AppHistoryApi to project a location from.
With either missing this adapter renders children untouched and demands
nothing of the surrounding app — no API provider, no framework context. That
passthrough is what lets one component wrap itself in the adapter and still
ship for both frontend systems: under the old frontend system there is no
page mount and no app history, and the wrap has to be invisible rather than
a crash. The same holds in a plugin's own render() unit tests.
React Router v6 page adapter. Injects library context projected from the framework's
AppHistoryApiand never writeswindow.historyvia push/replace/go.childrenare opaque React Router content (for example<Routes>/<Route>trees composed by the page itself, or the sub-page the framework routed to) and are rendered as-is. This adapter builds no routes of its own: which sub-page of a page is showing is decided by the framework's own route matching, one level above.Programmatic back and forward (
navigate(-1)) traverse the app-owned browser history.Declare it by rendering it inside the lazily loaded page or sub-page component that should get the context:
In a sub-page's component it scopes itself to that sub-page rather than to the page above it, because the sub-page's own mount is what is in context there. Adapters nest rather than replace one another, so a v6 sub-page works under a page rendered by another routing library, and the reverse.
Scoping needs two things: a page mount, saying which part of the URL belongs to the page, and a registered
AppHistoryApito project a location from. With either missing this adapter renderschildrenuntouched and demands nothing of the surrounding app — no API provider, no framework context. That passthrough is what lets one component wrap itself in the adapter and still ship for both frontend systems: under the old frontend system there is no page mount and no app history, and the wrap has to be invisible rather than a crash. The same holds in a plugin's ownrender()unit tests.