react-native 中的条件复选框

conditionnal checkbox in react-native

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

感谢您的帮助和抽出时间。

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

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>