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
+26
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
import { routerContext } from "./routerContext.js";
|
||||
import * as React$1 from "react";
|
||||
//#region src/useRouter.tsx
|
||||
/**
|
||||
* Access the current TanStack Router instance from React context.
|
||||
* Must be used within a `RouterProvider`.
|
||||
*
|
||||
* Options:
|
||||
* - `warn`: Log a warning if no router context is found (default: true).
|
||||
*
|
||||
* @returns The registered router instance.
|
||||
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
|
||||
*/
|
||||
function useRouter(opts) {
|
||||
const value = React$1.useContext(routerContext);
|
||||
if (!value) warnMissingRouter(opts);
|
||||
return value;
|
||||
}
|
||||
function warnMissingRouter(opts) {
|
||||
if (process.env.NODE_ENV !== "production" && (opts?.warn ?? true)) console.warn("Warning: useRouter must be used inside a <RouterProvider> component!");
|
||||
}
|
||||
//#endregion
|
||||
export { useRouter };
|
||||
|
||||
//# sourceMappingURL=useRouter.js.map
|
||||
Reference in new issue
Block a user