Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error react/prop-types , although the type has been specified #3521

Closed
2 tasks done
da-du opened this issue Jan 13, 2023 · 1 comment · Fixed by #3679
Closed
2 tasks done

[Bug]: Error react/prop-types , although the type has been specified #3521

da-du opened this issue Jan 13, 2023 · 1 comment · Fixed by #3679

Comments

@da-du
Copy link

da-du commented Jan 13, 2023

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

Error react/prop-types , although the type has been specified

this is error:

import React, { forwardRef, memo } from 'react';

interface Props1 {
    age: number;
}
export const Hello = memo(
    forwardRef(({ age }: Props1) => { // error: 'age' is missing in props validationeslint(react/prop-types)
        return <div>Hello {age}</div>;
    }),
);

but this is correct:

import React, { forwardRef, memo } from 'react';

interface Props1 {
    age: number;
}
const HelloTemp = forwardRef(({ age }: Props1) => {
    return <div>Hello {age}</div>;
});
export const Hello = memo(HelloTemp);

Expected Behavior

Expected no error

eslint-plugin-react version

v7.30.1

eslint version

v8.29.0

node version

v16.19.0

@ljharb
Copy link
Member

ljharb commented Apr 17, 2023

I've added failing tests in 4ea8102; the issue seems to be that it's not detecting declared propTypes in a component nested inside memo.

ljharb added a commit to developer-bandi/eslint-plugin-react that referenced this issue Jan 15, 2024
Fixes jsx-eslint#3521.

Co-authored-by: 김상두 <puki4416@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
@ljharb ljharb closed this as completed in 88f7f09 Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants