【发布时间】:2016-03-18 16:39:33
【问题描述】:
我一直在开发 React Web 应用,最近从 WebStorm 10 升级到了 2016.1。到目前为止,我对新版本感到满意,除了一些检查员的怪癖,如果我能提供帮助,我宁愿不要在场,其中一个我无法找到解决办法。
我正在使用 ES6 类来声明我的所有 React 组件,并且在我设置状态的每个实例中,WebStorm 都会在 .state 方法上抛出未解决的变量警告。
有问题的代码sn-p:
import React from "react";
import autobind from 'autobind-decorator';
@autobind
class List extends React.Component{
constructor() {
super();
this.state = {
name: "List",
items: {},
history: {},
suggestions: [],
highlightIndex: 0,
suggestionsHover: false,
autoDelete: true,
delta: 0,
mouse: 0,
isPressed: false,
lastPressed: 0,
order: []
}
}
警告:
Unresolved variable state
应该注意的是,这个警告在 WebStorm 10 中没有出现,并且警告会延续到设置状态的其他实例(即.setState)。还应该注意的是,我正在使用 babelify 将我的代码转换为 ES5 以及 autobind-decorator,如图所示。
任何帮助或见解将不胜感激。谢谢,如果我需要提供任何其他信息,请告诉我。
【问题讨论】:
-
听起来有些相似 -- 看看最后的 cmets -- intellij-support.jetbrains.com/hc/en-us/community/posts/…
标签: reactjs ecmascript-6 webstorm babeljs