UNPKG

@trpc/tanstack-react-query

Version:

TanStack React Query Integration for tRPC

1 lines • 1.43 kB
{"version":3,"file":"index.react-server.mjs","names":[],"sources":["../src/internals/clientOnly.ts"],"sourcesContent":["// Stand-ins for the client-only exports in the `react-server` build. React's\n// `react-server` build has no `createContext`, `useRef` and so on, so the real\n// ones must stay out of that build's module graph, or bundlers fail on it\n// (#6595). Like a `'use client'` reference, they throw if called on the server.\nimport type { createTRPCContext as createTRPCContextClient } from './Context';\nimport type { useSubscription as useSubscriptionClient } from './useSubscription';\n\nfunction throwClientOnly(name: string): never {\n throw new Error(\n `\\`${name}\\` works only in client components. ` +\n \"Call it from a module marked with 'use client'; in server components, use `createTRPCOptionsProxy`.\",\n );\n}\n\n/**\n * `createTRPCContext` for the `react-server` export condition.\n * @internal\n */\nexport const createTRPCContextReactServer: typeof createTRPCContextClient =\n () => throwClientOnly('createTRPCContext');\n\n/**\n * `useSubscription` for the `react-server` export condition.\n * @internal\n */\nexport const useSubscriptionReactServer: typeof useSubscriptionClient = () =>\n throwClientOnly('useSubscription');\n"],"mappings":";;AAOA,SAAS,gBAAgB,MAAqB;CAC5C,MAAM,IAAI,MACR,KAAK,KAAK,0IAEZ;AACF;;;;;AAMA,MAAa,qCACL,gBAAgB,mBAAmB;;;;;AAM3C,MAAa,mCACX,gBAAgB,iBAAiB"}