`react/no-this-in-sfc` when `this` does not refer to the SFC

Viewed 739
  const handleTweets = () => {
    $('.embed-tool__content--twitter').each(function () {

      // eslint-disable-next-line
      this.contentWindow.postMessage(
        {
          element: $(this).attr('id'),
          query: 'height'
        },
        'https://twitframe.com'
      );
    });
  };

I have this code inside a functional component. On removing eslint-disable-next-line, I am getting this error in ESLint:

Stateless functional components should not use `this`  react/no-this-in-sfc

Clearly, in my code, this refers to the HTMLElement binded to the (anonymous) function by JQuery, and not the SFC itself. Then why am I getting this error? Moreover, why in the next line, $(this) isn't throwing any error?

PS: I know I can directly use this.id. $(this).attr is just to provide MRE.

0 Answers
Related