I use WebStorm for React JS and I'm getting this 'Unresolved variable warning' by all props.
But everything works without problems, language is defined, it exists. Code works, I don't have any issues with my app.
This is what I have inside Languages & Frameworks > JavaScript > Libraries
Any idea how to avoid those warnings?
UPDATE
Code example where that happens. First parent component :
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>
)
}
}
Where language is an object {lowestPrice: "Lowest price", mileage: "Mileage", ....}
And then the component where I try to get those props, it works, but I get warning that they are unresolved :
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>
);
}
}
use destructuring assignment:
let {language} = this.props
instead let language = this.props.language;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With