react native中的conditional复选框



我想帮忙。我试图创造一个条件。如果产品有库存;必须选中复选框。如果不是,它一定是空的。我一点一点地摸索,我迷失在我的代码中。你能帮我一点忙吗?

谢谢你的帮助和时间。

这是代码的一部分(我知道条件根本不正确,这只是一个开始(:

export default class Products extends Component {
constructor(props) {
super(props);
this.state = {
checked: true,
stock : true, 
}
};
...
<View style={{ flexDirection: 'row' }}>
<CheckBox
value={this.state.stock ? !this.state.checked}
//onValueChange={() => this.setState({ checked: !this.state.checked })}
/>
<Text style={{marginTop: 5}}>Stock</Text>
</View>      

试试这个

<View pointerEvents="none">
<CheckBox
value={this.state.stock}
//onValueChange={() => this.setState({ checked: !this.state.checked })}
/>
</View>

最新更新