Skip to content

[Bug]: False positive on react/no-unused-prop-types with memo + forwardRef #3524

@luixo

Description

@luixo

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

When combining React.memo with React.forwardRef, react/no-unused-prop-types gives false positive.

import { Image } from "react-native";

type Props = {
  foo: string;
};

const LazyImage = React.memo<Props>(
  React.forwardRef<Image, Props>(
    ({ foo }, ref) => {
      console.log("foo", foo);
      return <Image ref={ref} />;
    }
  )
);

Expected Behavior

No error

eslint-plugin-react version

v7.32.0

eslint version

v8.31.0

node version

v16.17.0

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