Skip to content

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

@qooban

Description

@qooban

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions