[英]React-native 0.49 CheckBox How to change the prop : value ?
I'm trying to understand how to change the value of a checkbox that is new in React-native 0.49. 我试图了解如何更改React-native 0.49中新增的复选框的值。
<CheckBox
value = {this.state.value}
onValueChange= {(value) => this.toggleCheckBox(value)}
/>
And this is my toggleCheckbox function 这是我的toggleCheckbox函数
toggleCheckBox(data){
this.setProps({
value : data
});
The question is .. the function onValueChange only works once and once only. 问题是..函数onValueChange只工作一次。 the toggleCheckBox is called only once also I cant figure out how to update the value of checkbox.
toggleCheckBox仅被调用一次,我也无法弄清楚如何更新复选框的值。
You should use setState
. 您应该使用
setState
。
toggleCheckBox(data){
this.setState({value: data});
}
props
is uni-direction and cannot be modified. props
是单向的,无法修改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.