Next.js Discord

Discord Forum

@next/next/no-async-client-component

Unanswered
Nelson posted this in #help-forum
Open in Discord
I am using the latest canary version 13.4.8-canary.7.

@next/next/no-async-client-component page is not found.
https://nextjs.org/docs/app/building-your-application/configuring/eslint

'use client'

import { Skeleton } from '@codewithhong/ui'
import React from 'react'
import { useEvent } from 'react-use'

const CommentCounter = () => {
  const [counter, setCounter] = React.useState(-1)

  useEvent('message', (e: MessageEvent) => {
    if (e.origin !== 'https://giscus.app') return
    if (!(typeof e.data === 'object' && e.data.giscus)) return

    const giscus = e.data.giscus

    if (giscus.error) {
      setCounter(0)
      return
    }

    if (giscus.discussion) {
      setCounter(
        giscus.discussion.totalCommentCount + giscus.discussion.totalReplyCount
      )
    }
  })

  return (
    <>
      {counter < 0 ? (
        <Skeleton className='h-5 w-16' />
      ) : (
        <div>{`${counter} comments`}</div>
      )}
    </>
  )
}

export default CommentCounter


Error:
TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting E:\hong\dev\repos\honghong-me\src\app\blog\[slug]\comment-counter.tsx:1
Rule: "@next/next/no-async-client-component"


I don't know how to fix it.

12 Replies

@joulev it's not live yet, you can read it here https://github.com/vercel/next.js/blob/canary/errors/no-async-client-component.md
I read it. But I still have no idea how to fix it. I can't convert my component to a server component since I used useState. Also, my components don't have the async keyword.
Therefore, I downgrade eslint-config-next to v13.4.7 but keep the next canary version.
Thanks for your answer.
because there should be an async component in a client component file that throws this warning
and if you try to ignore it, your application may be having an infinite loop without your knowing
it is in this file?
eslint-config-next is buggy again haya smh
@Nelson https://github.com/codewithhong/honghong.me/blob/main/src/app/blog/%5Bslug%5D/comment-counter.tsx
I don't think there are any issues in my component. After updating eslint-config-next to canary version, I got this error. I think there is a bug in this rule.
yeah it is a bug in eslint-config-next; the file itself is fine at least as far as async client components are concerned
Oh, the problem is TypeError: Cannot read properties of undefined (reading 'type')
@joulev Just submitted a new issue: https://github.com/vercel/next.js/issues/51917, Thanks for your help.