javascript - react native - 如何在构造函数中使用状态
<p><p>我想在另一个状态的定义中使用一个状态,但我没有得到任何值(value)。<br/>
有人有什么想法吗??</p>
<pre><code>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()}
/>
)
};
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你可以在你的组件中使用它</p>
<pre><code> 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>}
}
</code></pre></p>
<p style="font-size: 20px;">关于javascript - react native - 如何在构造函数中使用状态,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/45456011/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/45456011/
</a>
</p>
页:
[1]