Server: Phase 2 (REVIEW not respected yet)
This commit is contained in:
1 parent
5d16ded553
commit
142b47674d
4271 files changed
+1203269
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
"use client";
|
||||
import { routerContext } from "./routerContext.js";
|
||||
import { Matches } from "./Matches.js";
|
||||
import { hasKeys } from "@tanstack/router-core";
|
||||
import "react";
|
||||
import { jsx } from "react/jsx-runtime";
|
||||
//#region src/RouterProvider.tsx
|
||||
/**
|
||||
* Low-level provider that places the router into React context and optionally
|
||||
* updates router options from props. Most apps should use `RouterProvider`.
|
||||
*/
|
||||
function RouterContextProvider({ router, children, ...rest }) {
|
||||
if (hasKeys(rest)) router.update({
|
||||
...router.options,
|
||||
...rest,
|
||||
context: {
|
||||
...router.options.context,
|
||||
...rest.context
|
||||
}
|
||||
});
|
||||
const provider = /* @__PURE__ */ jsx(routerContext.Provider, {
|
||||
value: router,
|
||||
children
|
||||
});
|
||||
if (router.options.Wrap) return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
|
||||
return provider;
|
||||
}
|
||||
/**
|
||||
* Renders the current match presentation and provides the router to the React
|
||||
* tree via context.
|
||||
*
|
||||
* Accepts mutable router options via props. Configure initialization-only
|
||||
* options with `createRouter`.
|
||||
*
|
||||
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
|
||||
*/
|
||||
function RouterProvider({ router, ...rest }) {
|
||||
return /* @__PURE__ */ jsx(RouterContextProvider, {
|
||||
router,
|
||||
...rest,
|
||||
children: /* @__PURE__ */ jsx(Matches, {})
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
export { RouterContextProvider, RouterProvider };
|
||||
|
||||
//# sourceMappingURL=RouterProvider.js.map
|
||||
Reference in new issue
Block a user