Kay
Kay
TtRPC
Created by Kay on 12/23/2023 in #❓-help
ReferenceError: Cannot access 'appRouter' before initialization
Hi friends im having trouble implementing a "protected" or "private" procedure in TRPC using Next.js 14 with NextAuth.
6 replies
TtRPC
Created by Kay on 12/14/2023 in #❓-help
Trpc calls being uncessarily made
Hi friends, i am relevatively new to TRPC so this could be somethign super basic. I have a component that is making a bunch of useQuery statements
export default function RegistryItem(props: IRegistryItemProps) {
const { data: session } = useSession();
const updateTeamRegistryById = TrpcClient.updateTeamRegistryById.useMutation({
onSettled: () => {
teamItems.refetch();
registryData.refetch();
},
});
console.log("item", props.item, "teamITem", props.teamItem);
const userId = session?.user?.id;
const teamId = session?.user.teamId;
const registryData = TrpcClient.getRegistryById.useQuery({ id: props.item.id });
const registry = registryData.data;
const teamItems = TrpcClient.getTeamRegistry.useQuery({ registryId: props.item.id, teamId: teamId as string });
const teamItem = teamItems.data;
const count = registry?.team_registry.filter((f) => f.enabled === true)?.length || 0;
...
export default function RegistryItem(props: IRegistryItemProps) {
const { data: session } = useSession();
const updateTeamRegistryById = TrpcClient.updateTeamRegistryById.useMutation({
onSettled: () => {
teamItems.refetch();
registryData.refetch();
},
});
console.log("item", props.item, "teamITem", props.teamItem);
const userId = session?.user?.id;
const teamId = session?.user.teamId;
const registryData = TrpcClient.getRegistryById.useQuery({ id: props.item.id });
const registry = registryData.data;
const teamItems = TrpcClient.getTeamRegistry.useQuery({ registryId: props.item.id, teamId: teamId as string });
const teamItem = teamItems.data;
const count = registry?.team_registry.filter((f) => f.enabled === true)?.length || 0;
...
Everytime i click on an empty space in the window, it refetches, happens also when switching tabs. This is causing a lot of unnecessary request. Why is this occuring?
7 replies