mercredi 2 décembre 2020

conditionnal checkbox in react-native

I would like to have a little help please. I am trying to create a condition. If the product is in stock; the checkbox must be checked. If it isn't, it must be empty. I fumble little by little and I get lost in my code. Could you give me a little help please?

Thank you for your help and your time.

here is part of the code (I know the condition is not correct at all, it's just a beginning of something) :

export default class Products extends Component {
  constructor(props) {
    super(props);
    this.state = {
      checked: true,
      stock : true, 
    }
  };

...

     <View style=>
       <CheckBox
          value={this.state.stock ? !this.state.checked}
          //onValueChange={() => this.setState({ checked: !this.state.checked })}
       />
       <Text style=>Stock</Text>
     </View>      



Aucun commentaire:

Enregistrer un commentaire