Flow (React Native) is giving me errors for using 'this.state'

后端 未结 4 1626
死守一世寂寞
死守一世寂寞 2021-01-01 08:34

Flow is giving me the following error whenever I try to use this.state in my code:

object literal: This type is incompatible with un

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 09:14

    You can ignore the state with flow type :any, but this is not recommended. You will get lost when your state get bigger and more complicated.

    class ExpandingCell extends Component {
    
        state: any;
    
        constructor(props) {
            super(props);
            this.state = {
                isExpanded: false
            };
        }
    }
    

提交回复
热议问题