在render和componentWillMount中未定义this.state

时间:2018-08-17 06:43:17

标签: react-native

我是新来的本地人。我已经定义了一个标志。但是,当我打印它的render和componentWillMount时,它最初显示为undefined,后来更改为true / false。有人帮忙。

constructor(props) {
    super(props);
    this.state = {
         flag: data ? true : false
    };
}

    componentWillMount() {
        console.log("Flag Status:", this.state.flag)
        }
    render(){
     console.log("Flag Status:", this.state.flag)
      }

0 个答案:

没有答案
相关问题