Implementing the questions page
The last page we will create is the Question page – this page will display the question along with the answers.
Again, before we start making components, we have to prepare the functions that call the GraphQL server inside our custom hook – just like we did for the Home page. To do that, let’s create a src/pages/Question/useQuestionQuery.ts
file with the following contents:
import { useClient } from '@/graphql/client'; import { QuestionDetailSelector, QuestionDetailType, } from '@/graphql/selectors'; import { useCallback, useEffect, useState } from 'react'; export const useQuestion = (questionId: string | undefined ) => { const [loadingState, setLoadingState] = useState< 'loading' | '404' | 'loaded' >('loading'); const [currentQuestion, setCurrentQuestion...