Flow is giving me the following error whenever I try to use this.state
in my code:
object literal: This type is incompatible with undefined. Did you forget to declare type parameter
State
of identifierComponent
?:
Here is the offending code (though it happens elsewhere too):
class ExpandingCell extends Component {
constructor(props) {
super(props);
this.state = {
isExpanded: false
};
}
Any help would be much appreciated =)
You need to define a type for the state property in order to use it.
class ComponentA extends Component {
state: {
isExpanded: Boolean
};
constructor(props) {
super(props);
this.state = {
isExpanded: false
};
}
}