Skip to content

Getting unrelated (react/no-this-in-sfc) violation error #1960

Closed
@psonawane-servicetitan

Description

@psonawane-servicetitan

I ran the following simple js program. But I got an error at line this.getA(); which is totally unrelated here. The error said "stateless functional components should not use this (react/no-this-in-sfc)"

class Demo {
    getA = () => 'a';

    hasBug = () => {
        this.getA();

        return null;
    };
}

What did you expect to happen?
No error expected

What actually happened? Please include the actual, raw output from ESLint.
Got this error - stateless functional components should not use this (react/no-this-in-sfc) for line this.getA()

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