thorin_17
thorin_17
TTCTheo's Typesafe Cult
Created by thorin_17 on 7/27/2023 in #questions
useState from TRPC Query
Hi - this is a noob question sorry. I'm wanting to create a dropdown of all the values returned by a query i.e. groups but I can't do a useState as I get Error: Rendered more hooks than during the previous render. This is my code:
import Head from "next/head";
import { useState } from "react";
import Header from "~/components/header";
import { api } from "~/utils/api";

export default function Admin() {
const groups = api.group.getAll.useQuery();

if (!groups.data) return <p>No Data</p>
if (groups.error) return <p>Error</p>

const [group, setGroup] = useState(groups.data[0])

return (
<>
<Head>
<title>Admin | Group</title>
</Head>
<Header pageTitle="Admin"/>
<p>Admin index page</p>
</>
)
}
import Head from "next/head";
import { useState } from "react";
import Header from "~/components/header";
import { api } from "~/utils/api";

export default function Admin() {
const groups = api.group.getAll.useQuery();

if (!groups.data) return <p>No Data</p>
if (groups.error) return <p>Error</p>

const [group, setGroup] = useState(groups.data[0])

return (
<>
<Head>
<title>Admin | Group</title>
</Head>
<Header pageTitle="Admin"/>
<p>Admin index page</p>
</>
)
}
17 replies
TTCTheo's Typesafe Cult
Created by thorin_17 on 5/13/2023 in #questions
How should I handle permissions for restricted pages?
E.g. Admin / Manager access pages with Read Update Create Delete specific permissions?
5 replies
TTCTheo's Typesafe Cult
Created by thorin_17 on 1/31/2023 in #questions
Using CASL with the T3 Stack
Look at https://github.com/stalniy/casl it seems quite cool, is it just a case of following the Prisma documentation? Or does anyone else have a good way of managing permissions?
1 replies