Skip to content

[Bug]: react/prefer-read-only-props doesn't work with async components #3653

Closed
@pnodet

Description

@pnodet

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

The code below does not trigger the rule. But if I remove the async keyword and the getData() the rule now errors correctly. I'm using nextjs app dir with server components.

type Props = {
  isInverted: boolean
}

const MyAsyncComponent = async ({ isInverted }: Props) => {
  const data = await getData();

  return (
    // some jsx
  )
}

Expected Behavior

Shouldn't the rule errors whether the component is async or not? Maybe I misunderstood something in the docs.

eslint-plugin-react version

v7.33.2

eslint version

v8.53.0

node version

v18.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions