Rendered more hooks than during the previous render Typescript error

Hey,

I have a parameter on my page that im loading with with router.query.
This is what my code looks like

const { studentId } = router.query;

if (typeof studentId !== "string") { return null; } else { const studentQp = api.coach.getStudentQps.useQuery({ studentId: studentId, }); rest of my code....

I did it this way to ensure typesafety, but if i put all of the trpc querys at the beginning of the page, i get typescript errors because the type of studentId is not checked first


How do i solve this?
Was this page helpful?