2016-11-28 275 views
5

我使用WebStorm for React JS,並且我得到了所有道具的「未解決的變量警告」。WebStorm未解決的變量警告

enter image description here

但一切正常沒有問題,語言的定義,它的存在。 代碼有效,我的應用程序沒有任何問題。

這是我裏面Languages & Frameworks > JavaScript > Libraries

enter image description here

任何想法如何避免這些警告?

UPDATE

代碼示例,其中出現這種情況。首先父組件:

import ExpirationTimer from '../../common/expirationTimer'; 

export default class ListView extends React.Component { 
    render(){ 
     const language = this.props.language; 
     let expirationDate = "Wed May 10 2017 15:58:59 GMT+0200"; 

     return (
      <div> 
       <ExpirationTimer expirationDate={expirationDate} language={language}/> 
      </div> 
     ) 
    } 
} 

其中語言是一個對象{lowestPrice: "Lowest price", mileage: "Mileage", ....}

然後該組件在那裏我試圖讓那些道具,它的工作原理,但我得到警告,他們沒有得到解決:

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

     this.state = {     
      expirationDate: this.props.expirationDate // Here I get the warning 
     }; 
    } 

    render(){ 
     let language = this.props.language; // Here I get the warning 


     return (
      <div> 
       ..... 
      </div> 
     ); 
    } 
} 
+0

你可以粘貼一小段代碼,發生這種情況,所以我可以在webstorm中重新創建文件並查看我在我的視圖中看到的內容嗎? –

+2

看起來像這是一個仍然沒有解決的已知問題:( –

+2

對我來說,當我禁用圖書館中「react-definitely typed」的錯誤消失 – lena

回答

1

使用解構賦值: let {language} = this.props 代替let language = this.props.language;