Top level 'this' expression

Webstorm 2019.1.1, React. After the last update I receive this message which should not appear

Reports this expressions occurring outside of object literals or constructor bodies. Such this expressions are legal JavaScript, and reference the top-level "global" JavaScript object, but are largely useless.

6
5 comments
Avatar
Permanently deleted user

Seeing the same issue.

0
Avatar
Permanently deleted user

Same here!

0

To provide some more detail: I see it in the render function here:

export default class Test extends React.Component {
constructor ( props ) {
super(props);

this.state = { data : props.data}
}

render() {
return <div>{this.state.data}</div>;
}
}

This should not be highlighted as a top level this, because it is bound to the instance the render method is invoked on.

1

Please sign in to leave a comment.