我正在使用React Typescript,并且我按照tRPC文档进行了服务器/客户端设置,但是我得到了这个错误。有人知道为什么在部署时会发生这个错误吗?当我在本地使用它时,它工作正常吗?
8:41:46 AM: TS2339: Property 'createClient' does not exist on type '"useContext collides with a built-in method, you should rename this router or procedure on your backend" | "Provider collides with a built-in method, you should rename this router or procedure on your backend" | "createClient collides with a built-in method, you should rename this router or procedure on your backend...'.
8:41:46 AM: Property 'createClient' does not exist on type '"useContext collides with a built-in method, you should rename this router or procedure on your backend"'.
8:41:46 AM: 42 | const [queryClient] = useState(() => new QueryClient());
8:41:46 AM: 43 | const [trpcClient] = useState(() =>
8:41:46 AM: > 44 | trpc.createClient({
8:41:46 AM: | ^^^^^^^^^^^^
8:41:46 AM: 45 | links: [
8:41:46 AM: 46 | httpBatchLink({
8:41:46 AM: 47 | url: `${process.env.REACT_APP_BACKEND_URL}/trpc`,
8:41:46 AM:
8:41:46 AM: "build.command" failed
我的应用程序.tsx
export default function App() {
const [queryClient] = useState(() => new QueryClient());
const [trpcClient] = useState(() =>
trpc.createClient({
links: [
httpBatchLink({
url: `${process.env.REACT_APP_BACKEND_URL}/trpc`,
}),
],
})
);
return (
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
........... rest of code here
1条答案
按热度按时间uelo1irk1#
这是因为您正在从后端导入
trpc
,这是因为您已经在本地编译了后端,但在Netlify/Vercel上部署时跳过了这一步。