use query results in state
Hi, I want to query my database for routes, and then set the DashboardState with the data from the query result. How can I do this?
interface DashboardState {
isNewRouteModalOpen: boolean;
isEditRouteModalOpen: boolean;
routes: Route[];
}
const initState: DashboardState = {
isNewRouteModalOpen: false,
isEditRouteModalOpen: false,
routes: [],
};
const Dashboard: NextPage = () => {
const [state, setState] = useState(initState);
const routes = api.example.getRoutes.useQuery();