Kratek
Kratek
TtRPC
Created by Kratek on 4/27/2023 in #❓-help
Generic handler for data.isLoading and data.isError
Hi, I'm looking for a way to create generic interface for useQuery result (budgetData from example below). My aim is to create generic function that handle isLoading and isError in every component. Example below:
const budgetData = api.budgets.getAllBudgets.useQuery();

if (budgetData.isLoading) {
return;
}

if (budgetData.isError) {
router.push(Routes.ERROR_500);
return null;
}
const budgetData = api.budgets.getAllBudgets.useQuery();

if (budgetData.isLoading) {
return;
}

if (budgetData.isError) {
router.push(Routes.ERROR_500);
return null;
}
Could you help me with it guys?
6 replies