'use client'; import { api } from '@repo/client'; import { Button } from '@repo/ui/components/button'; import { useState } from 'react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { httpBatchLink } from '@trpc/client'; function HomeContent() { const [name, setName] = useState(''); const helloQuery = api.hello.useQuery(name || undefined); return (
setName(e.target.value)} placeholder="输入名字" className="border p-2 mr-2" />
); } export default function Home() { const [queryClient] = useState(() => new QueryClient()); const [trpcClient] = useState(() => api.createClient({ links: [ httpBatchLink({ url: 'http://localhost:3000/api/trpc', }), ], }), ); return ( ); }