TRPC onClick

What is the best way to call a TRPC client on a button click. looking to get data from TPRC
4 Replies
cje
cje2y ago
disable the query and refetch on click
MrGreyKnight
MrGreyKnight2y ago
Any chance you have an example or links to the right bit of the docs? and does that change with the T3 tRPC setup?
cje
cje2y ago
const hello = api.example.hello.useQuery(
{ text: "from tRPC" },
{ enabled: false }
);

return <button onClick={() => void hello.refetch()}>Click me</button>;
const hello = api.example.hello.useQuery(
{ text: "from tRPC" },
{ enabled: false }
);

return <button onClick={() => void hello.refetch()}>Click me</button>;
the t3 trpc setup doesn't change anything its basically stock
MrGreyKnight
MrGreyKnight2y ago
Thanks much appreciated!
Want results from more Discord servers?
Add your server