To make state true or false

 

class Topup extends Component {
  constructor(props) {
    super(props);
    this.state = {
      ondiv: false,
      ondiv1: false,
      ondiv2: false,
      ondiv3: false,
      text: '',
      isloading: false,
    };
  }

  afterclickfivehundred() {
    this.setState({ ondiv: true });
    this.setState({ ondiv1: false });
    this.setState({ ondiv2: false });
    this.setState({ ondiv3: false });
    this.setState({ text: '500' });
    //alert("500");
  }
 
in View >>>>>>>>>>>>>>>>>>>>>>>>>> 
 
                <TouchableOpacity
                  style={{
                    backgroundColor: this.state.ondiv ? '#ffffff' : '#83a3f3',
                    width: '45%',
                    height: 120,
                    alignItems: 'center',
                    justifyContent: 'center',
                    borderRadius: 10,
                  }}
                  onPress={() => this.afterclickfivehundred()}
                >
                  <Image source={tick} style={styles.tickcss} resizeMode={'contain'} />
                  <Text
                    style={{
                      fontWeight: 'bold',
                      fontSize: 24,
                      color: this.state.ondiv ? '#000000' : '#ffffff',
                    }}
                  >
                    500
                  </Text>
                </TouchableOpacity>
 

Comments

Popular posts from this blog

Simple Redux

Add Axios Interceptor in Services where Api is called

React Interview Questions