2017-08-02 115 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>} 
} 
相關問題