Mattèo
Mattèo
TtRPC
Created by Mattèo on 2/14/2024 in #❓-help
Can I perform react query queries without using a trpc procedure, using useQuery standalone
Hey, I need to perform a client site request, and I can't implement it with TRPC, so can I use regular useQuery method in my Next.js app ? Will the useQuery will be attached to the React Query context of TRPC ?
2 replies
TtRPC
Created by Mattèo on 12/31/2023 in #❓-help
How to handle Query Errors on client side (show toast on 401)
Hey ! Hope you're doing well ! I wanted to know if someone can explain to me how to handle errors on the client (using Next.js). I need to handle UNAUTHENTICATED error on client because when a user tries to access a resource I want to display a feedback toast. Thanks 🙏
3 replies
TtRPC
Created by Mattèo on 12/9/2023 in #❓-help
How to create a React Component that fetch API based on a router from props ?
I want to pass in my React component props the name of the router to use, here is my current implementation :
export const RowActionDeleteButton = ({ id, model}: { id: string; model : 'lesson' | 'module' }) => {
const router = useRouter()

const deleteMutation = api[model].delete.useMutation({
onSuccess: () => {
router.reload()
toast.success(`Key ${id} deleted`)
},
onError: (err, variables) => {
router.reload()
toast.error(`Error deleting key ${id}`)
console.error(err, variables)
},
})

return (
// Error here : Type '[]' has no properties in common with type...
<Button variant="destructive" onClick={() => deleteMutation.mutate({ id })}>
Delete
</Button>
)
}
export const RowActionDeleteButton = ({ id, model}: { id: string; model : 'lesson' | 'module' }) => {
const router = useRouter()

const deleteMutation = api[model].delete.useMutation({
onSuccess: () => {
router.reload()
toast.success(`Key ${id} deleted`)
},
onError: (err, variables) => {
router.reload()
toast.error(`Error deleting key ${id}`)
console.error(err, variables)
},
})

return (
// Error here : Type '[]' has no properties in common with type...
<Button variant="destructive" onClick={() => deleteMutation.mutate({ id })}>
Delete
</Button>
)
}
Does someone already achieve something like this ?
3 replies
TtRPC
Created by Mattèo on 1/4/2023 in #❓-help
React Native Usage
Hello, I wanted to know if trpc can be used with react native ? And is it possible on a bare react native cli project ? Thanks, have a nice day !
2 replies