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.