import { useQuery } from '@apollo/client' import { useRouter } from 'next/router' import { useEffect } from 'react' import Comment, { CommentSkeleton } from './comment' export default function Comments ({ comments, ...props }) { useEffect(() => { // Your code here const hash = window.location.hash if (hash) { document.querySelector(hash).scrollIntoView({ behavior: 'smooth' }) } }, []) return comments.map(item => ( )) } export function CommentsSkeleton () { return } export function CommentsQuery ({ query, ...props }) { const router = useRouter() const { error, data } = useQuery(query, { fetchPolicy: router.query.cache ? 'cache-first' : undefined }) if (error) return
Failed to load!
if (!data) { return } return }