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

[react/destructuring-assignment] False positives when using render function inside an object #3022

Closed
qooban opened this issue Jul 22, 2021 · 3 comments

Comments

@qooban
Copy link

qooban commented Jul 22, 2021

With react/destructuring-assignment rule turned on, we get false positives for the case when render function is defined inside an object. Seems like such function is treated the same way as a render function inside React class component and the first argument of such function is expected to be destructured before use.

Reproduction example (TypeScript):

const test = {
    render(arg1: { id: string }, arg2: { id: string }) {
        return <div id={arg1.id} className={arg2.id} />;
    }
};

For such example ESLint reports: "Must use destructuring arg1 assignment(react/destructuring-assignment)". It does not report it for arg2.

eslint-plugin-react version: 7.24.0

@ljharb
Copy link
Member

ljharb commented Jul 22, 2021

Indeed, an uncapitalized function shouldn’t be detected as a component, and render on a plain object also shouldn’t.

@ohhoney1
Copy link
Contributor

#3001 fixed

@ljharb
Copy link
Member

ljharb commented Feb 22, 2022

Fixed in #3001.

@ljharb ljharb closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants