Kid
Kid

Reputation: 2205

Why is React ESLint saying I must use "this" in this particular method?

Why is this suggested by ESLint?
The Component does not even have this padding or margin as class fields.

slint

Upvotes: 0

Views: 103

Answers (1)

blade
blade

Reputation: 12894

Check the docs for the eslint rule class-methods-use-this.

If a class method does not use this, it can sometimes be made into a static function.

If you convert yout method into a static one, the warning will go away.

static _getListStyle() {
  // ...
}

Upvotes: 1

Related Questions