Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
12 replies
theFern

tRPC, query invalidation is not working

This is the code I have inside the component
const utils = trpc.useContext() const students = trpc.student.getAll.useQuery() const addStudentTRPC = trpc.student.add.useMutation({ onSuccess() { utils.student.getAll.invalidate() }, })

The mutation works fine but it doesn't invalidate the queries on success. I tried fetch(), refetch() and they don't work either. What am I missing?

Thanks!
Was this page helpful?