title: Flatlist or UseEffect goes into infinite loop when i am trying to fetch data from mongo db
body: <p>my fetching tickets page goes to infinite loop.  Can you help me please solve this problem.</p>
  <p>in this code i try get some data from server and then initial that in <code>state</code> with <code>useState</code>, after running it's trap in loop.</p>
  <pre><code>import axios from 'axios'
  import React, {useState, useEffect} from 'react'
  import { StyleSheet, Text, View, Image, TouchableOpacity, Button, FlatList } from 'react-native'
  import { TicketCard } from './tickets/TicketCard';
  
  export const TicketArea = () =&gt; {
     
          const [tickets, setTickets] = useState([])
          
      useEffect(() =&gt; {
          getTickets()
      },[])
  
      function getTickets() {
        axios.get('http://192.168.0.109:8800/api/ticket/ticketFindOne')
            .then(function (response) {
                setTickets(response.data)
                return;
            })
            .catch(function (error) {
                console.log(error)
            })
          }
  
      if (!tickets) {
          return null
      }
        
   
      return (
          &lt;View style={styles.container}&gt;
            &lt;FlatList
              data={tickets}
              keyExtractor={({id},index)=&gt;id}
              renderItem={ ({ item, index }) =&gt; (
                  &lt;TicketCard tickets={item} /&gt;
              )}
            /&gt;
          &lt;/View&gt;
      
      ) 
  }
          
  
  
  
  const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        
        minHeight: &quot;79%&quot;,
      }
      })
  </code></pre>
  <p>when i run project this gone to infinite loop.
  is <code>useEffect</code> correctly used in this class? any one can help?</p>