title: How to map array in flatlist in React Native
body: <p>I have functionality which will return me days of the week. Then I am mapping that array into <code>ScrollView</code>. I am able to do this succesfully.</p>
  <p>getting days of week functionality:</p>
  <pre><code>const [weekArray, changeWeekArrayState] = useState([]);
    useEffect(() =&gt; {
      var now = moment();
      let arrayDays = [];
      for (let i = 0; i &lt; 7; i++) {
        var day = now.format('ddd');
        var date = now.format('DD/MM/YYYY');
        if (i == 0) {
          day = 'Today';
        } else if (i == 1) {
          day = 'Tommorow';
        }
        arrayDays.push({
          day: day,
          date: date,
        });
        now.add(1, 'days');
      }
      changeWeekArrayState(arrayDays);
      console.log(weekArray);
    }, []);
  </code></pre>
  <p>Below is my code:</p>
  <pre><code>&lt;ScrollView
    horizontal={true}
    showsHorizontalScrollIndicator={false}&gt;
    {weekArray.map((item, index) =&gt; (
      &lt;TouchableOpacity
        index={index}
        onPress={() =&gt; setIndexSelect(index)}
        key={index}&gt;
        &lt;Text&gt;
          {index === weekArray.length - 1 ? ` ${item.day} ` : ` ${item.day} | `}
        &lt;/Text&gt;
      &lt;/TouchableOpacity&gt;
    ))}
  &lt;/ScrollView&gt;;
  </code></pre>
  <p>This works, But I wanted to do this using <code>FlatList</code>, so tried below given code:</p>
  <pre><code> &lt;FlatList
    horizontal={true}
    contentContainerStyle={styles.horizontalView}
    data={weekArray}
    renderItem={_renderItem}
    keyExtractor={(item) =&gt; item.day}
  /&gt;;
  
  const _renderItem = (item, index) =&gt; {
      &lt;TouchableOpacity
        index={index}
        onPress={() =&gt; setIndexSelect(index)}
        key={index}
      &gt;
        &lt;Text&gt;
          {index === weekArray.length - 1 ? ` ${item.day} ` : ` ${item.day} | `}
        &lt;/Text&gt;
      &lt;/TouchableOpacity&gt;
    }
  </code></pre>
  <p>I am getting just blank screen with this code.
  I am very new to using <code>FlatList</code> , so I am not able to figure out how to do this.</p>