2017-08-02 118 views
1

我想在另一个状态的定义中使用状态,但我没有任何价值。
有没有人有任何想法?反应原生态 - 如何在构造函数中使用状态

constructor(props) { 

    super(props); 

    this.state = { 

     check : false, 
     datatotal : this.props.services.map((d) => 
      <CheckBox 
       center 
       title={d} 
       checkedIcon='dot-circle-o' 
       uncheckedIcon='circle-o' 
       checked= {true} 
       onPress={() => this.checkBoxClick()} 
      /> 
    ) 

    }; 


} 
+0

'使用状态,但我什么也没得到value' , 这是什么意思?你能详细解释一下吗? – Val

回答

0

您可以使用此您的组件内部在其他国家的定义

constructor(props){ 
super(props); 
    this.state = { 
    check: false 
    } 
} 

render() { 
<View> 
{this.props.services && this.props.services.map(
    <CheckBox 
      center 
      title={d} 
      checkedIcon='dot-circle-o' 
      uncheckedIcon='circle-o' 
      checked= {true} 
      onPress={() => this.checkBoxClick()} 
     /> 
)</View>} 
} 
相关问题