title: React-native boolean=true only for concerned array and false for others, Flatlist
body: <p>I am trying to make sure that on press not all <code>this.state.users.expended=true</code> and only the one i've clicked on, the problem is that i am using flatlist and it is changing the state of all expanded in all array elements I've tried using loops, conditional statement and wrapping the array in another state but no result. can anyone help, thanks</p>
  
  <p>here is the code </p>
  
  <pre><code>import React, { Component } from 'react';
  import { View, Text, FlatList, Image, ImageBackground, PixelRatio, Platform, UIManager, TouchableOpacity, LayoutAnimation } from 'react-native';
  import {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen'
  import DropDownItem from 'react-native-drop-down-item';
  
  export default class App extends Component {
  
      constructor (props) {
      super(props)
      this.state ={
  
      users : [
    {
      spec1: require("./Icons/Growth.png"),
      spec2:require("./Icons/RED.png"),
      spec3:require("./Icons/LAGG.png"),
      name: 'Induce',
      price: '$',
      image: require("./Icons/RF.jpg"),
      icon: '',
      category: 'NA',
      textLeft:'',
      expanded: false      
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false      
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false     
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false       
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false     
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false       
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
    },
    {
      spec1: '5a31077f6dda99e234ad6727',
      name: 'Cathy Gilliam',
      price: 'EXOVENT',
      image: 'red',
      icon: '',
      expanded: false
  
    },
  
  ]
  
      }
      if (Platform.OS === 'android') {
        UIManager.setLayoutAnimationEnabledExperimental(true);
      }
  
        }
  
        changeLayout = () =&gt; {
          LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
  
          this.setState({ expanded: !this.state.expanded });
        }
  
         render() {
  
  
      return (
  
        &lt;View
        style={{
          backgroundColor:'#262A2C',
          flex:1
        }}&gt;
        &lt;FlatList
       style={{marginTop:80,}}
          data={this.state.users}
          renderItem={({ item }) =&gt; (
         &lt;View&gt;
  
            &lt;ImageBackground
  
            source={item.image} 
          //pay FlatIcon or design personal one
            style={{ 
  
              resizeMode: 'contain',
  
            position:'relative',
  
            width: wp('100%'), 
            left: wp('0%'),
            borderBottomWidth: 1,
            borderBottomColor: 'grey',
            padding: hp('6%'),
            }}
          &gt;
         &lt;View
              style={{
                flex:1,
               height:hp('19%'),
               width: wp('100%'),
               //height:hp('21%'),
  
                borderBottomColor: 'grey',
  
              }}&gt;
  
  
                 &lt;Image
                 style={{
                 width:wp('10%'),
                 height:hp('5%'),
                 left:wp('-10%'),
                 top:hp('-5.5%'),
                 //tintColor:'#81F018'
                 }}
                 source={item.spec1}/&gt;
                &lt;Image
                 style={{
                 width:wp('10%'),
                 height:hp('5.5%'),
                 left:wp('-10%'),
                 top:hp('0%'),
                 //tintColor:'#81F018'
                 }}
                 source={item.spec2}/&gt;
  
                 &lt;Image
                 style={{
                 width:wp('10%'),
                 height:hp('5.5%'),
                 left:wp('-10%'),
                 top:hp('6%'),
                 //tintColor:'#81F018'
                 }}
                 source={item.spec3}/&gt;
  
                &lt;Text 
                style={{ fontWeight: 'bold',
                 fontSize: 22, 
                 left:item.name.length&lt;=5 ? wp('32.5%'):wp('27.5%'),
                 top:hp('-9.5%'),
  
                 //left:item.name.length&lt;=5 ? wp('31.5%'):wp('26.5%'),
                 //top:hp('-1.5%')
                //left:item.name.length&lt;=5 ? wp('32.5%'):wp('27.5%'),
                 //top:hp('-3.5%')
                 }}&gt;
                 {item.name}
                 &lt;/Text&gt;
                &lt;Text
                style={{
                  fontWeight: 'bold',
                  fontSize: 25, 
                  top: hp('-25%'),
                  left:wp('80%')
                  // top: hp('-14%'),
                  //left:wp('80%')
                  //top: hp('-19%'),
                  //left:wp('80%')
                }}&gt;
                {item.price} 
                &lt;/Text&gt;
  
  
            &lt;/View&gt;
  
  
  
  
  
     &lt;/ImageBackground&gt;
     &lt;TouchableOpacity activeOpacity={0.8} onPress={this.changeLayout} style={{ padding: 10,
  
      backgroundColor:'black',
  
      left:wp('-10.9%'),
      top:hp('0%'),
      width: wp('120%'),
      height:hp('5%')}}&gt;
  
  &lt;/TouchableOpacity&gt;
  &lt;View style={{ height: this.state.expanded ? null : 0, overflow: 'hidden', backgroundColor:'black' }}&gt;
              &lt;Text style={{
                 fontSize: 17,
      color: 'white',
      padding: 10}}&gt;
                Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
                when an unknown printer took a galley of type and scrambled it to make a type specimen book.
                It has survived not only five centuries, but also the leap into electronic typesetting,
                remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
                containing Lorem Ipsum passages, and more recently with desktop publishing software
                like Aldus PageMaker including versions of Lorem Ipsum.
              &lt;/Text&gt;
            &lt;/View&gt;  
      &lt;/View&gt;
          )}
        /&gt;
        &lt;/View&gt;
      );
    }
  }
  </code></pre>