tRPC react-query hook not called on load

Hi there, my tRPC hook is not being called on page load and I can't figure out why. Here's what my /src/pages/poc.tsx page that uses the tRPC react-query hook look like:
export default function POC() {
const { data } = api.poc.get.useQuery();

return <pre>POC: {data}</pre>;
}
export default function POC() {
const { data } = api.poc.get.useQuery();

return <pre>POC: {data}</pre>;
}
and the router definition:
// ...
poc: createTRPCRouter({
get: publicProcedure.query(() => {
return "value from server";
}),
}),
// ...
// ...
poc: createTRPCRouter({
get: publicProcedure.query(() => {
return "value from server";
}),
}),
// ...
On page load, when I access localhost:3000/poc, I'd expect to see (1) a network requests for this request and (2) a logged message since I'm using a loggerLink (https://trpc.io/docs/client/links/loggerLink), but I'm getting none of these. There are no Typescript errors as well. Plus, if I console.log inside get, nothing (of course) gets printed out. Here's how api is defined as well:
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
};
},
ssr: false,
});
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
};
},
ssr: false,
});
What's going on? Why is the hook not called?
No description
Solution:
Actually, I just had to close and restart Arc. It works now. No idea why that happened 🤷‍♂️
Jump to solution
2 Replies
nco
nco5mo ago
Damn it looks like the issue is with Arc. Works in Chrome and Safari... thinkies
Solution
nco
nco5mo ago
Actually, I just had to close and restart Arc. It works now. No idea why that happened 🤷‍♂️
Want results from more Discord servers?
Add your server
More Posts
Next-auth.js: Redirect to custom URL after successful login.Hey all, I'm trying to figure out how to redirect after a successful login to a custom url. SpecificI has a long-running server task. I want to update my db afterwards. It's on the edge.Should I use TRPC on the edge runtime or prisma or update by supabase db direct? what's the cleanestuseForm vs useFormState in Nextjs v14Im just trying to understand the use case for using the react hook useForm over the react-dom useForParsing JSON Into zod schema using OPENAI GPTI want to parse a JSON example https://store.steampowered.com/api/appdetails?appids=1702010 Into laT3 Stack - Connect to MongodbI'm quite new to using the T3 stack, I have an application that needs to connect to MongoDB (I'm usiA social media message Aggregator platformHello there! I'm working on developing an app that acts as a central hub for users to connect with How can I globally manage errors in tRPC ? Trying `redirect` in custom link does not seem to workI want to be able to redirect a user when they become unauthenticated. Someone else mentioned to creHow to authenticate users on a dynamic sudomain (next-auth)Hey ! Hope you're doing well, I'm working on a project and I try to implement authentication on multRun Both Node and Bun Apps In a TurborepoHello, I was wondering if it possible to run both bun and node apps within the same turbo repo. I tserverCallback failing, receiving error on uploadThe upload works and I can see the file in the uploadthing dashboard, but I am still getting this er