title: change style in looping button react native
body: <p>i just start to learn react native <a href="https://i.stack.imgur.com/9t5PY.png" rel="nofollow noreferrer">i want to make ui like this</a>,
  i want the buttons on the image work like radio button, so user just can choose a button and change the button style choosed by user, and bellow is my code</p>
  
  <pre><code>class ButtonOption extends Component {
    constructor(props) {
      super(props);
      this.state = {
        data : [],
        active : 0
      };
    }
  
     loadButton(temp){
       let result = [];
       for (let i =0;i&lt;temp.length;i++){
         if(i==this.state.active){
           result.push(
           &lt;View key={i} style={buttonOption.main}&gt;
             &lt;TouchableOpacity style={buttonOption.tabActive} onPress={()=&gt;{this.setState({active:i});alert(this.state.active)}}&gt;
               &lt;Text style={buttonOption.labelActive}&gt;{temp[i]}&lt;/Text&gt;
             &lt;/TouchableOpacity&gt;
           &lt;/View&gt;)
         }else{
           result.push(
           &lt;View key={i} style={buttonOption.main}&gt;
             &lt;TouchableOpacity style={buttonOption.tab} onPress={()=&gt;{this.setState({active:i});alert(this.state.active)}}&gt;
               &lt;Text style={buttonOption.label}&gt;{temp[i]}&lt;/Text&gt;
             &lt;/TouchableOpacity&gt;
           &lt;/View&gt;)
         }
       }
       return result;
     }
  
     componentDidMount(){
       this.setState({data:this.loadButton(this.props.arrButton)})
     }
  
     render() {
      return (
        &lt;View style={{flexDirection:'row',padding:10}}&gt;
          {this.state.data}
        &lt;/View&gt;
      );
    }
  }
  export default ButtonOption;
  </code></pre>
  
  <p>on code above i was try to make button with looping, in looping function i use active as a state for check active button, and add function onPress so everytime user click button, active state will change, but when i run and choose button the active state won't change, what is wronge with my onPress code, can someone help please?</p>