Files
med-notes/.pnpm-store/v10/files/fd/61407dc8a2b1ff6b5344b5f1f2c1e1b2ac206560b8e0df0307ce68ecdb57b29d60662ec236ffe389f75b4360492a1748fc71f60ba39309b07d722d0f4c293a
2025-05-09 05:30:08 +02:00

25 lines
521 B
Plaintext

import * as React from 'react'
import type { AnyRouter } from '@tanstack/router-core'
declare global {
interface Window {
__TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>
}
}
const routerContext = React.createContext<AnyRouter>(null!)
export function getRouterContext() {
if (typeof document === 'undefined') {
return routerContext
}
if (window.__TSR_ROUTER_CONTEXT__) {
return window.__TSR_ROUTER_CONTEXT__
}
window.__TSR_ROUTER_CONTEXT__ = routerContext as any
return routerContext
}